-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfc for improving command suggestions #339
Conversation
Co-authored-by: Jordan Harband <ljharb@gmail.com>
|
||
I would suggest that we add a blessed property to errors thrown by commands `suggestions`. In the CLI framework, if a command rejects with an error that has this property, we display the suggestions. | ||
|
||
As for discovering the suggestions, we already have logic to find similarly named scripts based on levenshtein distance. This would need to be abstracted to a utility that can be consumed in `run-script` as well as `exec` and `help-search`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we do this, we could have the commands do something like throw Object.assign(new Error('unknown command'), { suggestions: listOfEveryAvailableCommand })
and let the Levenshtein distance pick the best ones to prompt?
I think (ironically) this RFC is blending together a few things into one, and in the spirit of this RFC, it should be made explicit. They are:
For (1), I think that this is exactly the right approach, and seems to be where we keep landing every time we discuss the tradeoffs involved in making For (2), this seems reasonable enough, though it is a breaking change, and definitely not uncontroversial. We could do a lot worse than copying git, and we have enough commands that some of the affordances have started to get a bit cluttered. For (3), it's worth noting that git recently added support for abbreviations on command-line switches, but not on top level commands. If a command is an unambiguous abbreviation for a known top-level command, it seems like we have enough to know what the user intended. For (4), I think the list could be examined and we could make some changes, but I am going to die on the hill of Ideas for a follow-up RFC:
|
this is intended to improve discoverability of a working command when a user runs something that does not work, notably this is an approach to addressing the needs of users who expect
npm foo
to work. instead of making an assumption that they want a script or binary, we will suggest that they try an explicit command that does one of those actions.References
Related to #336
Related to #332
Related to #279