mirror of https://github.com/spf13/cobra.git
provide usefull errors when using invalid sub command
This commit is contained in:
parent
10cf7be997
commit
140c5d89f1
|
@ -766,8 +766,11 @@ func (c *Command) Traverse(args []string) (*Command, []string, error) {
|
||||||
|
|
||||||
cmd := c.findNext(arg)
|
cmd := c.findNext(arg)
|
||||||
if cmd == nil {
|
if cmd == nil {
|
||||||
|
if c.Runnable() {
|
||||||
return c, args, nil
|
return c, args, nil
|
||||||
}
|
}
|
||||||
|
return c, args, legacyArgs(c, args)
|
||||||
|
}
|
||||||
|
|
||||||
if err := c.ParseFlags(flags); err != nil {
|
if err := c.ParseFlags(flags); err != nil {
|
||||||
return nil, args, err
|
return nil, args, err
|
||||||
|
|
Loading…
Reference in New Issue