Resolve conflict in completion flag check better

This commit is contained in:
Dan Buch 2017-08-12 22:07:03 -04:00
parent 65b801c818
commit 744fdb45b5
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7

22
help.go
View File

@ -318,21 +318,29 @@ func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) {
} }
func checkCompletions(c *Context) bool { func checkCompletions(c *Context) bool {
if c.shellComplete { if !c.shellComplete {
ShowCompletions(c) return false
return true
} }
if args := c.Args(); args.Present() {
name := args.First()
if cmd := c.App.Command(name); cmd != nil {
// let the command handle the completion
return false return false
}
}
ShowCompletions(c)
return true
} }
func checkCommandCompletions(c *Context, name string) bool { func checkCommandCompletions(c *Context, name string) bool {
if c.shellComplete { if !c.shellComplete {
ShowCommandCompletions(c, name) return false
return true
} }
return false ShowCommandCompletions(c, name)
return true
} }
func checkInitCompletion(c *Context) (bool, error) { func checkInitCompletion(c *Context) (bool, error) {