microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.95k stars 1.43k forks source link

PowerShell -MatchOption default should be EqualsCaseInsensitive #4737

Open ThomasNieto opened 4 weeks ago

ThomasNieto commented 4 weeks ago

Brief description of your issue

PowerShell is a case insensitive language, matching by case is opt-in. The MatchOption parameter default should be EqualsCaseInsensitive to have the standard PowerShell experience.

Steps to reproduce

Find-WinGetPackage -Id microsoft.powershell

Expected behavior

Only the matching Id is returned.

Find-WinGetPackage -Id microsoft.powershell

Name               Id                           Version Source
----               --                           ------- ------
PowerShell         Microsoft.PowerShell         7.4.4.0 winget

Actual behavior

The preview package is also being returned which should not happen unless PowerShell wildcards are used to do a like comparison instead of equals.

Find-WinGetPackage -Id microsoft.powershell

Name               Id                           Version Source
----               --                           ------- ------
PowerShell         Microsoft.PowerShell         7.4.4.0 winget
PowerShell Preview Microsoft.PowerShell.Preview 7.5.0.3 winget

Environment

Name                    Version
----                    -------
Microsoft.WinGet.Client 1.8.1911
stephengillie commented 3 weeks ago

[Policy] PowerShell

Trenly commented 3 weeks ago

The default behavior is to use a Substring search, which matches the WinGet CLI

[Policy] Issue Feature

denelon commented 2 weeks ago

@ThomasNieto, thanks for creating the issue. I'm still learning the PowerShell way and wouldn't have been likely to catch that once since I'm so used to the CLI experience. We should look to pass the right parameters via PowerShell to the COM API so the PowerShell experience matches the expectations here.

ThomasNieto commented 2 weeks ago

While testing some more it would be ideal to use the PowerShell way and use PowerShell wildcards. Right now even with the proposed setting it still returns other results other than the case insensitive match.

There is a class called WildcardPattern that you can use to ensure the match to the PowerShell way.