MCPcopy
hub / github.com/urfave/cli / suggestCommand

Function suggestCommand

suggestions.go:134–147  ·  view source on GitHub ↗

suggestCommand takes a list of commands and a provided string to suggest a command name

(commands []*Command, provided string)

Source from the content-addressed store, hash-verified

132// suggestCommand takes a list of commands and a provided string to suggest a
133// command name
134func 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}

Callers 1

TestSuggestCommandFunction · 0.85

Calls 2

jaroWinklerFunction · 0.85
NamesMethod · 0.65

Tested by 1

TestSuggestCommandFunction · 0.68