cobra
cobra copied to clipboard
Minimal distance : <Suggestions when "unknown command" happens> only works at first level ?
This is related to the 'minimal distance' between strings It seems that this functionality only works at first level of command, and not at sub-levels ?
Suggestions when "unknown command" happens only at first level of command
I have a three levels command, something like (presenting by level)
1/ mycmd
2/ mycmd list
mycmd modify
3/ mycmd list volumes
The suggestion works well for level 2 : if ever I do a typo on 'list' or 'modify' then I have the msg "Did you mean this?". But the suggestions does not work at all if I do a typo on the third level : a typo on 'volumes', 'disks', 'networks' does not generate the "Did you mean this?" message ?
I ve tried to play with such kind of code (see below), without success : volumesCmd.DisableSuggestions = false volumesCmd.SuggestionsMinimumDistance = 2 listCmd.AddCommand(volumesCmd)
Thank you for any help or clue !
This issue is being marked as stale due to a long period of inactivity
I am also interested in this ^
From this code it looks intentional but I'm wondering
- why is that?
- is there any way to make that configurable so that the lowest level commands (without subcommands) get suggestions for typos?
I agree on the surface that looks like a bug but may have been intentional due to some legacy support. Added tags to issue but still in need of someone to pick it up.
Hi @johnSchnake I already implemented a solution on https://github.com/spf13/cobra/pull/1500 but the maintainers of the repository had mixed thoughts about it and didn't get to a consensus how to address this issue since it will break backward compatibility. @jpmcb let me know if you think it should be implemented or whether we can close this issue.