Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions godoc-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" .}}

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 12 additions & 5 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions testdata/godoc-v3.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" .}}

Expand Down Expand Up @@ -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.
Expand Down
Loading