mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Remove specail casing in Execute()
We had some stuff that created a new empty []string if args was already and empty string (why?) We had some stuff that called Help() if it wasn't runnable (but .execute() already does that) Just remove the special case stuff.
This commit is contained in:
parent
b9e25fa4a0
commit
794a362808
1 changed files with 3 additions and 14 deletions
17
command.go
17
command.go
|
@ -476,20 +476,9 @@ func (c *Command) Execute() (err error) {
|
||||||
args = c.args
|
args = c.args
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) == 0 {
|
cmd, flags, err := c.Find(args)
|
||||||
// Only the executable is called and the root is runnable, run it
|
if err == nil {
|
||||||
if c.Runnable() {
|
err = cmd.execute(flags)
|
||||||
err = c.execute([]string(nil))
|
|
||||||
} else {
|
|
||||||
c.Help()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cmd, flags, e := c.Find(args)
|
|
||||||
if e != nil {
|
|
||||||
err = e
|
|
||||||
} else {
|
|
||||||
err = cmd.execute(flags)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue