show only subcommand flags with bash completion

This commit is contained in:
Zack Scholl 2020-09-17 12:46:05 -07:00
parent d2d2098085
commit a8e44a8b5b

View File

@ -164,9 +164,10 @@ func DefaultCompleteWithFlags(cmd *Command) func(c *Context) {
if len(os.Args) > 2 {
lastArg := os.Args[len(os.Args)-2]
if strings.HasPrefix(lastArg, "-") {
printFlagSuggestions(lastArg, c.App.Flags, c.App.Writer)
if cmd != nil {
printFlagSuggestions(lastArg, cmd.Flags, c.App.Writer)
} else {
printFlagSuggestions(lastArg, c.App.Flags, c.App.Writer)
}
return
}