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

Add a "Did you mean?" prompt if user misspells example name, and optionally re-run if the user says "Yes!" #17

Open
rnag opened this issue Apr 17, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rnag
Copy link
Owner

rnag commented Apr 17, 2022

Is your feature request related to a problem? Please describe.

I don't know if it's possible but I'd like to suggest auto-correction if a user misspells or mistypes an example name, similar to how cargo run --example does it already currently.

Related Issues

#18

Describe the solution you'd like

Potentially something like:


Sorry bud, no such example `my_exmaple` exists.

Did you mean `my_example`? [Y/N]:  $  
Did you mean `my_example`? [Y/N]:  $  y

[Runs the example file `my_example`...]

Describe alternatives you've considered

I haven't actually looked into any existing solutions for spelling correction yet. It would be cool to implement this, I feel. Preferably with the least overhead in terms of overall dependency size, compilation or build time, etc.

Additional context

It's not too necessary as when we call cargo run --example, it'll already offer an auto correction hint. But I think it's nice to add proactive spellchecking and correction -- this way it'll be a little faster, as we can catch the error earlier, and we don't need to waste time spawning a new process to call cargo run --example when we already know the example name is misspelled, for example.

Just for completeness sake, Here's a sample auto correction hint from cargo run --example on one of my projects, which I think is really cool/nice:

PS serde-this-or-that> cargo run --example d
error: no example target named `d`

        Did you mean `demo`?
@rnag rnag added the enhancement New feature or request label Apr 17, 2022
@rnag rnag changed the title Add "did you mean?" prompt if user misspells example name, and optionally re-run if the user says "yes!" Add "did you mean?" prompt if user misspells example name, and optionally re-run if the user says "Yes!" Apr 17, 2022
@rnag rnag changed the title Add "did you mean?" prompt if user misspells example name, and optionally re-run if the user says "Yes!" Add a "Did you mean?" prompt if user misspells example name, and optionally re-run if the user says "Yes!" Apr 17, 2022
@rnag rnag added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant