Delete name field from Command (#547)

Discussion: https://github.com/spf13/cobra/pull/422#discussion_r143918343
This commit is contained in:
Albert Nigmatzianov 2017-10-11 16:15:37 +02:00 committed by Eric Paris
parent 845c905010
commit 40f18800b2
1 changed files with 5 additions and 10 deletions

View File

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