Skip to content
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

Provide better did-you-mean suggestions for swapped words #5029

Open
not-my-profile opened this issue Jul 20, 2023 · 3 comments · May be fixed by #4997
Open

Provide better did-you-mean suggestions for swapped words #5029

not-my-profile opened this issue Jul 20, 2023 · 3 comments · May be fixed by #4997
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@not-my-profile
Copy link
Contributor

While using the deno CLI (which uses clap) I experienced the following:

$ deno check --write-lock
error: unexpected argument '--write-lock' found

  tip: a similar argument exists: '--no-lock'

The option I wanted was --lock-write.

Another example would be ripgrep e.g. rg --not-type currently suggests --no-pre when it should really be suggesting --type-not.

@epage epage added C-enhancement Category: Raise on the bar on expectations A-help Area: documentation, including docs.rs, readme, examples, etc... S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing labels Jul 20, 2023
@epage
Copy link
Member

epage commented Jul 20, 2023

Carrying some of the conversation from the PR

So this will only check for one-"word" swaps and only if the word separator is - (which it really should be) and won't handle typos within those swapped words.

The thing I'm tying to decide if this is too narrow of a niche to include

@epage
Copy link
Member

epage commented Jul 20, 2023

@not-my-profile

Right ... if you want to I can convert the PR to a draft and we can discuss this in an issue.

Personally I think mixing up the order of words of CLI arguments happens much more often for me than misspelling them. E.g. ripgrep has --type-not ... trying --not-type instead is a very easy mistake to make but clap currently suggests --no-pre. I think a small quality of life improvement like this across all clap CLIs would be nice ... sure this logic could be made more elaborate to also handle swaps in arguments consisting of e.g. 3 words but I think 2 word flags are much more common.

@epage
Copy link
Member

epage commented Jul 20, 2023

I want to sit on this to give this more thought. I'm trying to weigh out the couple of specific cases this helps with vs where the line is for us supporting these one-off heuristics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants