FindCmd finds the matching Cmd for args. It returns the Cmd and the remaining args.
(args []string)
| 122 | // FindCmd finds the matching Cmd for args. |
| 123 | // It returns the Cmd and the remaining args. |
| 124 | func (c Cmd) FindCmd(args []string) (*Cmd, []string) { |
| 125 | var cmd *Cmd |
| 126 | for i, arg := range args { |
| 127 | if cmd1 := c.findChildCmd(arg); cmd1 != nil { |
| 128 | cmd = cmd1 |
| 129 | c = *cmd |
| 130 | continue |
| 131 | } |
| 132 | return cmd, args[i:] |
| 133 | } |
| 134 | return cmd, nil |
| 135 | } |
| 136 | |
| 137 | type cmdSorter []*Cmd |
| 138 |