provide usefull errors when using invalid sub command

This commit is contained in:
Uwe Krueger 2022-06-02 11:08:19 +02:00
parent 10cf7be997
commit 140c5d89f1
1 changed files with 4 additions and 1 deletions

View File

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