diff --git a/godoc-current.txt b/godoc-current.txt index 13dcbe2bca..6afd244f25 100644 --- a/godoc-current.txt +++ b/godoc-current.txt @@ -205,6 +205,9 @@ func ShowAppHelpAndExit(c *Context, exitCode int) ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code. +func ShowCommandCompletions(ctx *Context, command string) + ShowCommandCompletions prints the custom completions for a given command + func ShowCommandHelp(ctx *Context, command string) error ShowCommandHelp prints help for the given command diff --git a/help.go b/help.go index c40cacbad6..c7b8f55a58 100644 --- a/help.go +++ b/help.go @@ -314,6 +314,19 @@ func ShowCompletions(cCtx *Context) { } } +// ShowCommandCompletions prints the custom completions for a given command +func ShowCommandCompletions(ctx *Context, command string) { + c := ctx.Command.Command(command) + if c != nil { + if c.BashComplete != nil { + c.BashComplete(ctx) + } else { + DefaultCompleteWithFlags(c)(ctx) + } + } + +} + // printHelpCustom is the default implementation of HelpPrinterCustom. // // The customFuncs map will be combined with a default template.FuncMap to diff --git a/testdata/godoc-v2.x.txt b/testdata/godoc-v2.x.txt index 13dcbe2bca..6afd244f25 100644 --- a/testdata/godoc-v2.x.txt +++ b/testdata/godoc-v2.x.txt @@ -205,6 +205,9 @@ func ShowAppHelpAndExit(c *Context, exitCode int) ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code. +func ShowCommandCompletions(ctx *Context, command string) + ShowCommandCompletions prints the custom completions for a given command + func ShowCommandHelp(ctx *Context, command string) error ShowCommandHelp prints help for the given command