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
Conversation
c19e787
to
34e954b
Compare
We could consider other names of the parameter: -Fuzzy, -FuzzyMatching, -ShowSuggestions, -Suggestions. We need PowerShell Committee approvement for the new public API. |
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 |
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
Outdated
Show resolved
Hide resolved
@rjmholt I suggest we defer the test hook as that would make sense for testing suggestions in general and not this specific change. |
It was good to have a tracking issue if we needed these special tests. |
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
Outdated
Show resolved
Hide resolved
@SteveL-MSFT Do you want to wait on Rob to review your changes? |
@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 |
It would be good to fix some style issues and "s_" before merge. |
@PowerShell/powershell-committee reviewed this and is ok with |
…eful in finding close matches
removed use of Tuple and created struct
1d51a6d
to
580911b
Compare
PR Summary
Add
-UseFuzzyMatching
switch toGet-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 aCommandNotFound
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.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.-UseFuzzyMatching
switch added toGet-Command
MicrosoftDocs/PowerShell-Docs#3429[feature]
if the change is significant or affects feature tests