mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Add support to show suggestions on CommandNotFound exception (#8458)
* support fuzzy matching with get-command and on CommandNotFound exception, show suggestion * fix CodeFactor issues * change algorithm to use Damerau-Levenshtein Distance which is more useful in finding close matches
This commit is contained in:
1 parent
a3d55783cd
commit
b87cd1c0a3
8 files changed
+292
-24
No files matched your search
@@ -0,0 +1,23 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
Describe "Get-Command CI tests" -Tag Feature {
|
||||
Context "-UseFuzzyMatch tests" {
|
||||
It "Should match cmdlets" {
|
||||
$cmds = Get-Command get-hlp -UseFuzzyMatch
|
||||
$cmds.Count | Should -BeGreaterThan 0
|
||||
$cmds[0].Name | Should -BeExactly 'Get-Help' -Because "This should be closest match so shows up first"
|
||||
}
|
||||
|
||||
It "Should match native commands" {
|
||||
$ping = "ping"
|
||||
if ($IsWindows) {
|
||||
$ping = "PING.EXE"
|
||||
}
|
||||
|
||||
$cmds = Get-Command pin -UseFuzzyMatch
|
||||
$cmds.Count | Should -BeGreaterThan 0
|
||||
$cmds.Name | Should -Contain $ping
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user