Skip to content

Suggest alternative when command not found#6256

Merged
rgwood merged 4 commits intonushell:mainfrom
rgwood:command-suggestions
Aug 7, 2022
Merged

Suggest alternative when command not found#6256
rgwood merged 4 commits intonushell:mainfrom
rgwood:command-suggestions

Conversation

@rgwood
Copy link
Copy Markdown
Contributor

@rgwood rgwood commented Aug 7, 2022

Description

Closes #4996. When the user tries to run foo but the command can't be found:

  1. Check if foo matches any search terms for other commands
  2. Check if foo is similar to other command names (maybe it's a typo)

Before

image

After

image

Before

image

After

image

Future Work

Once this is in place, we could probably delete the deprecated internal commands (as long as the right search terms exist for their replacements).

Tests

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace --features=extra to check that all the tests pass

@sophiajt
Copy link
Copy Markdown
Contributor

sophiajt commented Aug 7, 2022

Like it!

One small tweak you might want to try is making the error label be did you mean.

On phone, but imagining the second image's label could be did you mean 'benchmark'?

@rgwood
Copy link
Copy Markdown
Contributor Author

rgwood commented Aug 7, 2022

@jntrnr Good idea. Just to confirm that we're on the same page, something like this?
image

@sophiajt
Copy link
Copy Markdown
Contributor

sophiajt commented Aug 7, 2022

@rgwood - yeah exactly

@rgwood
Copy link
Copy Markdown
Contributor Author

rgwood commented Aug 7, 2022

Done.

image

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Aug 7, 2022

really like this @rgwood! good work.

@rgwood rgwood merged commit 84fae6e into nushell:main Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve command not found error message with search terms

3 participants