MCPcopy
hub / github.com/cloudfoundry/cli / Suggest

Method Suggest

util/command_parser/unknown_command_error.go:16–31  ·  view source on GitHub ↗
(pluginCommandNames []string)

Source from the content-addressed store, hash-verified

14}
15
16func (e *UnknownCommandError) Suggest(pluginCommandNames []string) {
17 var commandNames []string
18
19 commandListStruct := reflect.TypeOf(common.Commands)
20 commandListStruct.FieldByNameFunc(
21 func(fieldName string) bool {
22 field, _ := commandListStruct.FieldByName(fieldName)
23 if commandName := field.Tag.Get("command"); commandName != "" {
24 commandNames = append(commandNames, commandName)
25 }
26 return false
27 })
28
29 cmdSuggester := spellcheck.NewCommandSuggester(append(commandNames, pluginCommandNames...))
30 e.suggestions = cmdSuggester.Recommend(e.CommandName)
31}
32
33func (e UnknownCommandError) Error() string {
34 message := fmt.Sprintf("'%s' is not a registered command. See 'cf help -a'", e.CommandName)

Callers 1

mainFunction · 0.80

Calls 3

RecommendMethod · 0.95
NewCommandSuggesterFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected