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 support to show suggestions on CommandNotFound exception #8458

Merged
merged 6 commits into from Jan 10, 2019

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Dec 13, 2018

PR Summary

Add -UseFuzzyMatching switch to Get-Command to return commands that fuzzy match to the name in order of closest match to least. Integrate this with the suggestion framework so that on a CommandNotFound exception, suggestions are shown for likely commands the user intended. The suggestions are part of the console host and write directly to the console so don't see a way to test that. In the future, we should consider changing that to using information stream.

Example usage

PR Checklist

@iSazonov
Copy link
Collaborator

We could consider other names of the parameter: -Fuzzy, -FuzzyMatching, -ShowSuggestions, -Suggestions.

We need PowerShell Committee approvement for the new public API.

@SteveL-MSFT SteveL-MSFT added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Dec 14, 2018
@rjmholt
Copy link
Collaborator

rjmholt commented Dec 17, 2018

We could introduce a test hook to do something like write output to the information stream or to a variable for testing purposes for now

@SteveL-MSFT
Copy link
Member Author

@rjmholt I suggest we defer the test hook as that would make sense for testing suggestions in general and not this specific change.

@iSazonov
Copy link
Collaborator

It was good to have a tracking issue if we needed these special tests.

@SteveL-MSFT
Copy link
Member Author

@iSazonov created #8486

@TravisEz13
Copy link
Member

@SteveL-MSFT Do you want to wait on Rob to review your changes?

@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Jan 4, 2019

@TravisEz13 if @rjmholt has further comments, we can treat it as a separate issue and PR. Would like to get this in for next Preview

@iSazonov
Copy link
Collaborator

iSazonov commented Jan 4, 2019

It would be good to fix some style issues and "s_" before merge.

@SteveL-MSFT
Copy link
Member Author

@PowerShell/powershell-committee reviewed this and is ok with -UseFuzzyMatching

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jan 9, 2019
support fuzzy matching with get-command and on CommandNotFound exception, show suggestion
removed use of Tuple and created struct
@TravisEz13 TravisEz13 added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Jan 10, 2019
@TravisEz13 TravisEz13 merged commit b87cd1c into PowerShell:master Jan 10, 2019
@SteveL-MSFT SteveL-MSFT deleted the fuzzy-match branch January 10, 2019 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants