effect icon indicating copy to clipboard operation
effect copied to clipboard

cli: add help for incorrectly spelled commands

Open jessekelly881 opened this issue 1 year ago • 0 comments

What is the problem this feature would solve?

When a user incorrectly type a cli argument it would be ideal if the cli helped the user find the right command instead of erroring. Git and many other cli tools tell the user what command they might be thinking of and some prompt the user to run the suggested command instead. For example, if you run git comit` git will reply with

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

The most similar command is
        commit

At the moment the effect cli just errors.

Compare: Screenshot 2024-10-03 at 3 04 46 PM

to: Screenshot 2024-10-03 at 3 05 14 PM

What is the feature you are proposing to solve the problem?

I think we should handle this case better. When effect cli detects that the user incorrectly typed either a command or an argument it should suggest the closest command name (if one is close enough) and ask the user if they want to run that instead using a yes/no prompt.

This should be done automatically by the effect cli framework without the cli implementer having to change anything.

https://www.npmjs.com/package/didyoumean2

What alternatives have you considered?

Implementing this manually for every cli is possible but is not fun..

jessekelly881 avatar Oct 03 '24 21:10 jessekelly881