suggestCommand takes a list of commands and a provided string to suggest a command name
(commands []*Command, provided string)
| 132 | // suggestCommand takes a list of commands and a provided string to suggest a |
| 133 | // command name |
| 134 | func suggestCommand(commands []*Command, provided string) (suggestion string) { |
| 135 | distance := 0.0 |
| 136 | for _, command := range commands { |
| 137 | for _, name := range append(command.Names(), helpName, helpAlias) { |
| 138 | newDistance := jaroWinkler(name, provided) |
| 139 | if newDistance > distance { |
| 140 | distance = newDistance |
| 141 | suggestion = name |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return suggestion |
| 147 | } |