Skip to content

Minimal distance : <Suggestions when "unknown command" happens> only works at first level ? #834

@dsgrangs-paul

Description

@dsgrangs-paul

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
mycmd list disks
mycmd list networks
mycmd modify volumes
mycmd modify disks
mycmd modify networks

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/flags-argsChanges to functionality around command line flags and argskind/bugA bug in cobra; unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions