rvesse / airline

Java annotation-based framework for parsing Git like command line structures with deep extensibility
https://rvesse.github.io/airline/
Apache License 2.0
128 stars 20 forks source link

Automatically suggest possible commands when the command is not recognised #62

Open rvesse opened 7 years ago

rvesse commented 7 years ago

Currently if you use an unrecognised command name this simply results in an error. It would be nice if we did something similar to git where we try to suggest what commands the user actually meant to use e.g.

git brac
git: 'brac' is not a git command. See 'git --help'.

Did you mean this?
    branch

To do this we would need to modify the CLI parser so that when it cannot find a command and there is no suitable default command we try and suggest commands. By computing string similarity between the user inputs and the actual command names we could rank possible commands and show the most appropriate suggestions.

rvesse commented 5 years ago

The existing Suggester classes possibly do this but they haven’t been touched since 0.x so would need testing and validating

Providing a specific error handler that falls over to the suggested when a command/option is not understood might also be useful