-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Change default sort order on search. #142
Comments
Same for the 'show' command. I don't want it to be sorted by the ID but the name. |
Currently, is there any way to display all apps alphabetically at all? |
I started an implementation of this feature in #1205. |
There is currently a sort order defined by the search itself (as mentioned in the OP). It is currently sorted by (applies to the
Quality here means whether the match was exact, a substring, etc. So this means that
This would actually be placed before "Git" in the results with name sorting only. I would imagine that the large majority of users searching for "git" are not looking for this at all though. These 4 also fall into the same bucket:
If users still want results to be sorted purely based on name, I would think it best to have a setting rather than change the default (or have a setting and change the default). |
I copied the original body of the Issue from a comment, and I never got back around to clarifying. Thanks for jumping in @JohnMcPMS. Yes, we do need to think about how sorting can impact results. I think what we currently have is similar to "best-match".
|
@JohnMcPMS I see, thanks for explaining! I wasn't aware that there was already some logic for sorting implemented. I fully agree that always sorting by name seems like a step back to what we currently have, at least for the output of Maybe this feature also becomes somewhat obsolete once there are PowerShell cmdlets for winget as you could then just use the sorting available in PowerShell. |
+1 for |
I could definitely get behind |
So this is a hack and a half, but in PowerShell it approximates alpha sort by name: $nameVar = winget list ; $namevar[4..($namevar.length)] | Sort-Object | Format-Table You lose out on the headers this way. This is my even uglier (in code) table-formatted version. There's probably a graceful way to do this, but I'm just trying to bang out something that works. I hard-coded the column widths because I felt that some egregiously long names (Microsoft Security Updates primarily) ruined the entire table. $wingetListOutput = winget list | Where-Object {$_ -notlike "*$([char]0x0008)*" -and $_ -notlike "*----------*"}
$wingetListOutputCSV = $wingetListOutput -replace '[ ]{2,}',','
$wingetListOutputCSV | ConvertFrom-Csv | Sort-Object -Property Name | Format-Table -Property @{ e='Name'; width = 30 }, @{ e='Id'; width = 60 }, @{ e='Version'; width = 20 }, @{ e='Available'; width = 20 }, Source I'm gonna slap this in an alias and call it a day. Again, it's a frankenscript and it would definitely be best if the functionality were incorporated in WT. |
@ehawman-rosenberg I decided to use the lack of alphabetised listing as an opportunity to take a quick look at the PowerShell module called Crescendo (Github: https://github.com/PowerShell/Crescendo):
but.. I immediately hit the problem that I think you've got, which is the lack of data present in the 'Available' column/property means the table gets jumbled up like this: I couldn't think of an immediate solution but found this amazing bit of code: https://github.com/iRon7/ConvertFrom-SourceTable/blob/master/ConvertFrom-SourceTable.ps1 which solves the problem (once you've wrapped it into a Example:
and Wrapping this up in Crescendo gives a new cmdlet "Invoke-WinGet": The
and
I find it somewhat amusing that we're using PowerShell to solve this problem when Chocolatey is native PowerShell and does the same thing as WinGet, essentially 😅 EDIT: Tweaked the code returned from winget output so it filters out progress bar lines (which resulted in errors when passing to |
@robinmalik you might want to take a look at https://github.com/microsoft/winget-cli/tree/master/tools/PowerShell I participated in a hackathon to build PowerShell cmdlets. We were considering Crescendo but ended up doing more manual work due to the impedance of our command names vs approved PowerShell Nouns and Verbs. There may be some useful code there, and we would welcome any improvements :) |
Pardon the n00b question: how do you do that? ( Cheers. |
@robinmalik hey there, was curious if you have made any progress on the addition of Crescendo? or if anyone else has been working on a similar solution. |
@aycippo They're doing it officially now. In amongst the assets for the latest release there's the module zipped up: https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.WinGet.Client-PSModule.zip |
Having just had a very quick look at it, this works: To filter by those with updates available you have to use the
(I wasn't able to pipe to |
[Policy] Area-Output |
@robinmalik do we have an issue covering your finding with the "PowerShell" label? |
@denelon I personally haven't created an issue for that encountered error. I can do, if you'd like? |
Yes, please. 😊 |
@denelon Happy to report that having installed the latest version from the PowerShell Gallery (congrats on getting it up there!) that the |
I would like the ability to customize the sort order when multiple results are returned.
In addition to arguments like
winget search _foo_ -sort Name
, I would like settings to specify my default preferences.winget list -sort Version
In addition, I would like to have settings to handle results from multiple sources so they can be displayed in a coalesced manner vs. the default where we sort by source based on their order in
winget source list
.The text was updated successfully, but these errors were encountered: