Writing tests around changes from #1186

This commit is contained in:
2022-04-21 20:07:06 -04:00
parent 7a231c5eb1
commit c4c15e1453
2 changed files with 93 additions and 4 deletions
+10 -4
View File
@@ -163,20 +163,26 @@ func DefaultCompleteWithFlags(cmd *Command) func(c *Context) {
return func(c *Context) {
if len(os.Args) > 2 {
lastArg := os.Args[len(os.Args)-2]
if strings.HasPrefix(lastArg, "-") {
if cmd != nil {
printFlagSuggestions(lastArg, cmd.Flags, c.App.Writer)
} else {
printFlagSuggestions(lastArg, c.App.Flags, c.App.Writer)
return
}
printFlagSuggestions(lastArg, c.App.Flags, c.App.Writer)
return
}
}
if cmd != nil {
printCommandSuggestions(cmd.Subcommands, c.App.Writer)
} else {
printCommandSuggestions(c.App.Commands, c.App.Writer)
return
}
printCommandSuggestions(c.App.Commands, c.App.Writer)
}
}