(next string)
| 796 | } |
| 797 | |
| 798 | func (c *Command) findNext(next string) *Command { |
| 799 | matches := make([]*Command, 0) |
| 800 | for _, cmd := range c.commands { |
| 801 | if commandNameMatches(cmd.Name(), next) || cmd.HasAlias(next) { |
| 802 | cmd.commandCalledAs.name = next |
| 803 | return cmd |
| 804 | } |
| 805 | if EnablePrefixMatching && cmd.hasNameOrAliasPrefix(next) { |
| 806 | matches = append(matches, cmd) |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | if len(matches) == 1 { |
| 811 | // Temporarily disable gosec G602, which produces a false positive. |
| 812 | // See https://github.com/securego/gosec/issues/1005. |
| 813 | return matches[0] // #nosec G602 |
| 814 | } |
| 815 | |
| 816 | return nil |
| 817 | } |
| 818 | |
| 819 | // Traverse the command tree to find the command, and parse args for |
| 820 | // each parent. |
no test coverage detected