(pluginCommandNames []string)
| 14 | } |
| 15 | |
| 16 | func (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 | |
| 33 | func (e UnknownCommandError) Error() string { |
| 34 | message := fmt.Sprintf("'%s' is not a registered command. See 'cf help -a'", e.CommandName) |
no test coverage detected