Merge pull request #1054 from itchyny/subcommand-consistent-description
Fix description of subcommand more consistent
This commit is contained in:
commit
ffbb8c04e4
@ -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…
Reference in New Issue
Block a user