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

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

@SteveL-MSFT SteveL-MSFT requested review from rjmholt, anmenaga and PaulHigin Dec 13, 2018
@SteveL-MSFT SteveL-MSFT requested review from BrucePay and daxian-dbw as code owners Dec 13, 2018
@SteveL-MSFT SteveL-MSFT force-pushed the SteveL-MSFT:fuzzy-match branch 3 times, most recently from c19e787 to 34e954b Dec 13, 2018
@SteveL-MSFT SteveL-MSFT referenced this pull request Dec 14, 2018
2 of 9 tasks complete
@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented Dec 14, 2018

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

We need PowerShell Committee approvement for the new public API.

@rjmholt

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

commented Dec 18, 2018

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

@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented Dec 18, 2018

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

@SteveL-MSFT

This comment has been minimized.

Copy link
Member Author

commented Dec 18, 2018

@iSazonov created #8486

@TravisEz13

This comment has been minimized.

Copy link
Member

commented Jan 3, 2019

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

@SteveL-MSFT

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link
Collaborator

commented Jan 4, 2019

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

@SteveL-MSFT

This comment has been minimized.

Copy link
Member Author

commented Jan 9, 2019

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

SteveL-MSFT added 4 commits Dec 13, 2018
support fuzzy matching with get-command and on CommandNotFound exception, show suggestion
removed use of Tuple and created struct
@SteveL-MSFT SteveL-MSFT force-pushed the SteveL-MSFT:fuzzy-match branch from 1d51a6d to 580911b Jan 10, 2019
@TravisEz13 TravisEz13 merged commit b87cd1c into PowerShell:master Jan 10, 2019
7 checks passed
7 checks passed
CodeFactor 16 issues fixed. 16 issues found.
Details
PowerShell-CI-linux #PR-8458-20190110.01 succeeded
Details
PowerShell-CI-macos #PR-8458-20190110.01 succeeded
Details
PowerShell-CI-static-analysis #PR-8458-20190110.01 succeeded
Details
PowerShell-CI-windows #PR-8458-20190110.02 succeeded
Details
WIP Ready for review
Details
license/cla All CLA requirements met.
Details
@SteveL-MSFT SteveL-MSFT deleted the SteveL-MSFT:fuzzy-match branch Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.