diff --git a/godoc-current.txt b/godoc-current.txt index edd42feb88..aa3ca2d73c 100644 --- a/godoc-current.txt +++ b/godoc-current.txt @@ -131,6 +131,15 @@ COPYRIGHT: cli.go uses text/template to render templates. You can render custom help text by setting this variable. +var ShowAppHelp = showAppHelp + ShowAppHelp is an action that displays the help + +var ShowCommandHelp = showCommandHelp + ShowCommandHelp prints help for the given command + +var ShowSubcommandHelp = showSubcommandHelp + ShowSubcommandHelp prints help for the given subcommand + var SubcommandHelpTemplate = `NAME: {{template "helpNameTemplate" .}} @@ -195,22 +204,13 @@ func HandleExitCoder(err error) This function is the default error-handling behavior for an App. -func ShowAppHelp(cmd *Command) error - ShowAppHelp is an action that displays the help. - func ShowAppHelpAndExit(cmd *Command, exitCode int) ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code. -func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error - ShowCommandHelp prints help for the given command - func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, code int) ShowCommandHelpAndExit - exits with code after showing help -func ShowSubcommandHelp(cmd *Command) error - ShowSubcommandHelp prints help for the given subcommand - func ShowSubcommandHelpAndExit(cmd *Command, exitCode int) ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits with exit code. diff --git a/help.go b/help.go index c039a5d02b..42e14a854d 100644 --- a/help.go +++ b/help.go @@ -44,6 +44,15 @@ var HelpPrinterCustom helpPrinterCustom = printHelpCustom // VersionPrinter prints the version for the App var VersionPrinter = printVersion +// ShowAppHelp is an action that displays the help +var ShowAppHelp = showAppHelp + +// ShowCommandHelp prints help for the given command +var ShowCommandHelp = showCommandHelp + +// ShowSubcommandHelp prints help for the given subcommand +var ShowSubcommandHelp = showSubcommandHelp + func buildHelpCommand(withAction bool) *Command { cmd := &Command{ Name: helpName, @@ -131,7 +140,7 @@ func ShowAppHelpAndExit(cmd *Command, exitCode int) { } // ShowAppHelp is an action that displays the help. -func ShowAppHelp(cmd *Command) error { +func showAppHelp(cmd *Command) error { tmpl := cmd.CustomRootCommandHelpTemplate if tmpl == "" { tracef("using RootCommandHelpTemplate") @@ -270,8 +279,7 @@ func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, c os.Exit(code) } -// ShowCommandHelp prints help for the given command -func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error { +func showCommandHelp(ctx context.Context, cmd *Command, commandName string) error { for _, subCmd := range cmd.Commands { if !subCmd.HasName(commandName) { continue @@ -322,8 +330,7 @@ func ShowSubcommandHelpAndExit(cmd *Command, exitCode int) { os.Exit(exitCode) } -// ShowSubcommandHelp prints help for the given subcommand -func ShowSubcommandHelp(cmd *Command) error { +func showSubcommandHelp(cmd *Command) error { HelpPrinter(cmd.Root().Writer, SubcommandHelpTemplate, cmd) return nil } diff --git a/testdata/godoc-v3.x.txt b/testdata/godoc-v3.x.txt index edd42feb88..aa3ca2d73c 100644 --- a/testdata/godoc-v3.x.txt +++ b/testdata/godoc-v3.x.txt @@ -131,6 +131,15 @@ COPYRIGHT: cli.go uses text/template to render templates. You can render custom help text by setting this variable. +var ShowAppHelp = showAppHelp + ShowAppHelp is an action that displays the help + +var ShowCommandHelp = showCommandHelp + ShowCommandHelp prints help for the given command + +var ShowSubcommandHelp = showSubcommandHelp + ShowSubcommandHelp prints help for the given subcommand + var SubcommandHelpTemplate = `NAME: {{template "helpNameTemplate" .}} @@ -195,22 +204,13 @@ func HandleExitCoder(err error) This function is the default error-handling behavior for an App. -func ShowAppHelp(cmd *Command) error - ShowAppHelp is an action that displays the help. - func ShowAppHelpAndExit(cmd *Command, exitCode int) ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code. -func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error - ShowCommandHelp prints help for the given command - func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, code int) ShowCommandHelpAndExit - exits with code after showing help -func ShowSubcommandHelp(cmd *Command) error - ShowSubcommandHelp prints help for the given subcommand - func ShowSubcommandHelpAndExit(cmd *Command, exitCode int) ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits with exit code.