diff --git a/command.go b/command.go index 87d0791..4d4b391 100644 --- a/command.go +++ b/command.go @@ -128,8 +128,6 @@ type Command struct { // TraverseChildren parses flags on all parents before executing child command. TraverseChildren bool - // name is the command name, usually the executable's name. - name string // commands is the list of commands supported by this program. commands []*Command // parent is a parent command for this command. @@ -1047,15 +1045,12 @@ func (c *Command) DebugFlags() { // Name returns the command's name: the first word in the use line. func (c *Command) Name() string { - if c.name == "" { - name := c.Use - i := strings.Index(name, " ") - if i >= 0 { - name = name[:i] - } - c.name = name + name := c.Use + i := strings.Index(name, " ") + if i >= 0 { + name = name[:i] } - return c.name + return name } // HasAlias determines if a given string is an alias of the command.