diff --git a/app.go b/app.go index 9d5e82c..0c4333e 100644 --- a/app.go +++ b/app.go @@ -198,9 +198,11 @@ func (a *App) Setup() { var newCommands []*Command for _, c := range a.Commands { - if c.HelpName == "" { - c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name) + cname := c.Name + if c.HelpName != "" { + cname = c.HelpName } + c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname) c.flagCategories = newFlagCategoriesFromFlags(c.Flags) newCommands = append(newCommands, c) diff --git a/app_test.go b/app_test.go index 1f5805a..834b37d 100644 --- a/app_test.go +++ b/app_test.go @@ -1914,12 +1914,12 @@ func TestApp_Run_CommandHelpName(t *testing.T) { output := buf.String() - expected := "command foo bar - does bar things" + expected := "command custom bar - does bar things" if !strings.Contains(output, expected) { t.Errorf("expected %q in output: %s", expected, output) } - expected = "command foo bar [command options] [arguments...]" + expected = "command custom bar [command options] [arguments...]" if !strings.Contains(output, expected) { t.Errorf("expected %q in output: %s", expected, output) } diff --git a/command.go b/command.go index fa48094..a63048d 100644 --- a/command.go +++ b/command.go @@ -107,10 +107,6 @@ func (cmd *Command) Command(name string) *Command { } func (c *Command) setup(ctx *Context) { - if c.HelpName == "" { - c.HelpName = fmt.Sprintf("%s %s", ctx.parentContext.Command.HelpName, c.Name) - } - if c.Command(helpCommand.Name) == nil && !c.HideHelp { if !c.HideHelpCommand { c.Subcommands = append(c.Subcommands, helpCommand) diff --git a/help_test.go b/help_test.go index 2a17df5..2341f58 100644 --- a/help_test.go +++ b/help_test.go @@ -504,13 +504,13 @@ func TestShowSubcommandHelp_CommandAliases(t *testing.T) { func TestShowCommandHelp_Customtemplate(t *testing.T) { app := &App{ + Name: "foo", Commands: []*Command{ { Name: "frobbly", Action: func(ctx *Context) error { return nil }, - HelpName: "foo frobbly", CustomHelpTemplate: `NAME: {{.HelpName}} - {{.Usage}}