diff --git a/app_test.go b/app_test.go index 2f3e89d..61c55d8 100644 --- a/app_test.go +++ b/app_test.go @@ -1567,7 +1567,8 @@ func TestApp_Run_CommandSubcommandHelpName(t *testing.T) { } cmd := &Command{ Name: "foo", - Description: "foo commands", + Usage: "foo commands", + Description: "This is a description", Subcommands: []*Command{subCmd}, } app.Commands = []*Command{cmd} @@ -1584,6 +1585,11 @@ func TestApp_Run_CommandSubcommandHelpName(t *testing.T) { t.Errorf("expected %q in output: %q", expected, output) } + expected = "DESCRIPTION:\n This is a description\n" + if !strings.Contains(output, expected) { + t.Errorf("expected %q in output: %q", expected, output) + } + expected = "base foo command [command options] [arguments...]" if !strings.Contains(output, expected) { t.Errorf("expected %q in output: %q", expected, output) diff --git a/template.go b/template.go index 7c651f1..aee3e04 100644 --- a/template.go +++ b/template.go @@ -56,10 +56,13 @@ OPTIONS: // cli.go uses text/template to render templates. You can // render custom help text by setting this variable. var SubcommandHelpTemplate = `NAME: - {{.HelpName}} - {{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}} + {{.HelpName}} - {{.Usage}} USAGE: - {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} + {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}} + +DESCRIPTION: + {{.Description}}{{end}} COMMANDS:{{range .VisibleCategories}}{{if .Name}} {{.Name}}:{{range .VisibleCommands}}