cobra
cobra copied to clipboard
Proposal: Make command suggestion messages configurable
Hi, we have a project where clear definitions were made, what the output of the CLI has to look like. We appreciate the automatic suggestions if a command was misspelled. Sadly it seems like we cannot customize the suggestion message and the default message doesn't really fit with the rest of the CLI.
Is there a possibility to make a SetSuggestFunc()
like it's been done with SetHelpFunc()
?
This could be used to change the suggestion message:
rootCmd.SetSuggestFunc(func(suggestedCommands []*cobra.Command) {
var commandNames string
for _, command := range suggestedCommands {
commandNames += command.Use + " "
}
fmt.Printf("Did you mean any of [%s]", commandNames)
})