fix description of subcommand more consistent

main
itchyny 4 years ago
parent 3f8c3bca57
commit aed5577db6

@ -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)

@ -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}}

Loading…
Cancel
Save