mirror of https://github.com/spf13/cobra.git
Delete name field from Command (#547)
Discussion: https://github.com/spf13/cobra/pull/422#discussion_r143918343
This commit is contained in:
parent
845c905010
commit
40f18800b2
15
command.go
15
command.go
|
@ -128,8 +128,6 @@ type Command struct {
|
||||||
// TraverseChildren parses flags on all parents before executing child command.
|
// TraverseChildren parses flags on all parents before executing child command.
|
||||||
TraverseChildren bool
|
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 is the list of commands supported by this program.
|
||||||
commands []*Command
|
commands []*Command
|
||||||
// parent is a parent command for this 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.
|
// Name returns the command's name: the first word in the use line.
|
||||||
func (c *Command) Name() string {
|
func (c *Command) Name() string {
|
||||||
if c.name == "" {
|
name := c.Use
|
||||||
name := c.Use
|
i := strings.Index(name, " ")
|
||||||
i := strings.Index(name, " ")
|
if i >= 0 {
|
||||||
if i >= 0 {
|
name = name[:i]
|
||||||
name = name[:i]
|
|
||||||
}
|
|
||||||
c.name = name
|
|
||||||
}
|
}
|
||||||
return c.name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasAlias determines if a given string is an alias of the command.
|
// HasAlias determines if a given string is an alias of the command.
|
||||||
|
|
Loading…
Reference in New Issue