From 744fdb45b5a844910c56f66c0b8be2cc23a7f5ce Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 12 Aug 2017 22:07:03 -0400 Subject: [PATCH] Resolve conflict in completion flag check better --- help.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/help.go b/help.go index a722564..02fcf33 100644 --- a/help.go +++ b/help.go @@ -318,21 +318,29 @@ func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) { } func checkCompletions(c *Context) bool { - if c.shellComplete { - ShowCompletions(c) - return true + if !c.shellComplete { + return false } - return false + 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 + } + } + + ShowCompletions(c) + return true } func checkCommandCompletions(c *Context, name string) bool { - if c.shellComplete { - ShowCommandCompletions(c, name) - return true + if !c.shellComplete { + return false } - return false + ShowCommandCompletions(c, name) + return true } func checkInitCompletion(c *Context) (bool, error) {