Skip to content

Commit

Permalink
Make find command check case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
saheljalal committed Sep 6, 2019
1 parent 881c749 commit 8fd0ab2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ func Find(name string) {

for _, cmd := range cfg.Manifest.Commands {
cmd.Walk(func(c *model.Command, s *bool) {
if strings.Contains(c.Name, name) || strings.Contains(c.Alias, name) {
if containsCaseInsensitive(c.Name, name) || containsCaseInsensitive(c.Alias, name) {
matchingCmds = append(matchingCmds, c)
}
for _, sub := range c.Subs {
if strings.Contains(sub.Name, name) || strings.Contains(sub.Alias, name) {
if containsCaseInsensitive(sub.Name, name) || containsCaseInsensitive(sub.Alias, name) {
matchingSubs = append(matchingSubs, c)
}
}
Expand Down Expand Up @@ -315,3 +315,7 @@ func sanitizeArgs(args []string) []string {
}
return sanitizedArgs
}

func containsCaseInsensitive(s, substr string) bool {
return strings.Contains(strings.ToLower(s), strings.ToLower(substr))
}

0 comments on commit 8fd0ab2

Please sign in to comment.