winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Improvements to the list command

Open denelon opened this issue 4 years ago • 17 comments

Description of the new feature/enhancement

We need to build a cache to improve performance for the list command.

We need to record everything installed by the Windows Package Manager explicitly.

Proposed technical implementation details (optional)

denelon avatar May 14 '21 17:05 denelon

We need to record everything installed by the Windows Package Manager explicitly.

Hey @denelon glad to see this issue! For me and likely many other users, this is an essential feature needed before adopting winget as a default package manager.

It's a bit more than just an inconvenience because the situation is compounded by the fact that many current winget users also use chocolatey, scoop, or both, and so the ability to list packages installed specifically with winget should be considered a vital operation. I would argue that this issue is worthy of a high priorty 👍

ev-dev avatar May 24 '21 00:05 ev-dev

@ev-dev be sure to add your 👍 to the issue. We often sort by most 👍 to find high priority / high value features. We have a large number of Issues in v.Next right now to evaluate for v1.1.

denelon avatar May 24 '21 14:05 denelon

while there is a search option in the consoles of cmd and PowerShell (Ctrl+F) there is no search in Windows Terminal yet.

How about: The list command (same as search) has an an optional paged output as if you would pipe it to "more" e.g. get-childitem (ls) | more

just tested winget search / list support piping to more.

examples:

winget list -p / winget list --p winget search -p / winget list --p

Karl-WE avatar May 25 '21 20:05 Karl-WE

I have just discovered winget, but the the winget list order makes no sense (at least not to me)

Is there a way to get a list sorted in alphabetical order of the package names? I would use | sort in Linux, but I'm not familiar with PowerShell syntax

jypeter avatar Sep 08 '22 13:09 jypeter

@JohnMcPMS do you know what might be driving the order of the output for winget list?

denelon avatar Sep 08 '22 15:09 denelon

I'm experimenting with winget again, and I'm surprised there is still no way to get a usable sorted list of winget list. That's a shame, as winget list output is getting bigger and bigger each time I use it!

  • I see that the related https://github.com/microsoft/winget-cli/issues/142 was opened more than 2 years ago...
  • Even the sorting order in the example provided in the official winget list documentation makes no obvious sense

My use case here is that I have recently installed the emacs text editor with winget install --id GNU.Emacs (it was really nice to be able to do that!), and I wanted to use winget list to check which version I had. I ended up scrolling back and forth several times to check the output and not finding anything

Now, I have also use the following, and found out that emacs did not appear in the list at all, but that's probably another problem (maybe some packages don't appear in the list, because something was not done properly in the installation package). EDIT: I see this has been recently mentioned in https://github.com/microsoft/winget-pkgs/issues/88443

PS C:\Users\your_login> winget list --id GNU.Emacs
Aucun package installé ne correspond aux critères saisis.

I can do the following, with WSL installed, but it's kind of an overkill. And I don't want to learn PowerShell syntax (I'm a Linux user and I like python and bash for scripting)

PS C:\Users\jypeter> winget list | wsl sort

-----------------------------------------------------------------------------------------------------------------------
3D Builder                             Microsoft.3DBuilder_8wekyb3d8bbwe      18.0.1931.0
7-Zip 22.01 (x64)                      7zip.7zip                              22.01                              winget
Adobe Acrobat Reader - Fran??ais        {AC76BA86-7AD7-1036-7B44-AC0F074E4100} 22.003.20282
Adobe Acrobat XI Pro                   {AC76BA86-1033-FFFF-7760-000000000006} 11.0.23
Adobe Flash Player 32 NPAPI            {FDC0C70F-866A-49EF-A886-D7FE22409CDA} 32.0.0.156
Adobe Genuine Service                  AdobeGenuineService                    8.1.0.3
Adobe Illustrator CS6                  {4869414E-7AEA-4C8E-BE1C-8D40977FD517} 16.0
Amazon Games                           Amazon.Games                           2.2.8063.2                         winget

jypeter avatar Dec 15 '22 13:12 jypeter

[Policy] Command-List

@denelon / @stephengillie - Also should have Area-Performance

Trenly avatar Jun 16 '23 16:06 Trenly

I have just used winget list again, and the default list order still does not make any obvious sense. I'm apparently using winget v1.7.11261

I see I can get a more sensible output using winget list | sort https://github.com/microsoft/winget-cli/issues/4238#issuecomment-1987358760. It's good to know that you can use a pipe in PowerShell, but a sensible defaut order and additional sort options would not hurt

jypeter avatar Jun 04 '24 14:06 jypeter

~Please consider using the PowerShell cmdlets for the package manager, such as Get-WinGetPackage, which should have equivalent output to winget list. And these output PSObjects which can be easier to work with and manipulate than raw strings.~

stephengillie avatar Jun 04 '24 15:06 stephengillie

Trouble is that I only use PowerShell as a terminal (in a Windows Terminal)

I mostly use Linux related shells and programming tools on remote servers, and I'm not going to spend time learning PS prpgramming, unless it exactly matches what I already use for Linux (like winget list | sort)

jypeter avatar Jun 05 '24 12:06 jypeter

~Ah - please accept this as a type of workaround: If you're going to implement winget list | sort, then a slight change to Get-WinGetPackage | sort name should give more consistent results, while also adding the ability to sort by column.~

~For instance:~

  • ~Get-WinGetPackage | sort name to have the output sorted by package name~
  • ~Get-WinGetPackage | sort Id to have the output sorted by PackageIdentifier~

~And this would work for Version and Source columns as well.~

~Edit: Need to specify the column name for Get-WinGetPackage, or sort doesn't know which column to sort against, it would seem, as it returns unsorted results. Guessing this doesn't happen with winget list because it's only returning a string array for sort to interpret.~

stephengillie avatar Jun 05 '24 14:06 stephengillie

I have directly pasted the command in a PS, but I'm getting a command not found error. Am I doing something wrong, or do I have to install some extra stuff (providing Get-WinGetPackage)?

PS C:\Users\jypeter> Get-WinGetPackage | sort name
Get-WinGetPackage : Le terme «Get-WinGetPackage» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou programme
exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est correct et réessayez.
Au caractère Ligne:1 : 1
+ Get-WinGetPackage | sort name
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-WinGetPackage:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

jypeter avatar Jun 05 '24 14:06 jypeter

~Sorry, I thought these would be present. The module might need to be installed and imported:~

  • ~Install-Module Microsoft.WinGet.Client~
  • ~Import-Module Microsoft.WinGet.Client~

~If this is too far afield, it's okay.~

stephengillie avatar Jun 05 '24 15:06 stephengillie

Read earlier that PS 7.x and 5.1 differ for thes capabilities of the module. Where PS 7.x takes the lead.

Karl-WE avatar Jun 05 '24 21:06 Karl-WE

Thanks @stephengillie !

I have succesfully used the Install-Module Microsoft.WinGet.Client and Import-Module Microsoft.WinGet.Client commands

I had to use an elevated PS and accept something called NuGet. I hope all of this is legit

PS C:\Users\jypeter> Install-Module Microsoft.WinGet.Client

Le fournisseur NuGet est requis pour continuer
PowerShellGet requiert le fournisseur NuGet, version 2.8.5.201 ou ultérieure, pour interagir avec les référentiels
NuGet. Le fournisseur NuGet doit être disponible dans « C:\Program Files\PackageManagement\ProviderAssemblies » ou «
C:\Users\jypeter\AppData\Local\PackageManagement\ProviderAssemblies ». Vous pouvez également installer le fournisseur
NuGet en exécutant la commande « Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force ». Voulez-vous
que PowerShellGet installe et importe le fournisseur NuGet maintenant ?
[O] Oui  [N] Non  [S] Suspendre  [?] Aide (la valeur par défaut est « O ») : O

Référentiel non approuvé
Vous installez les modules à partir d'un référentiel non approuvé. Si vous approuvez ce référentiel, modifiez sa valeur
 InstallationPolicy en exécutant l'applet de commande Set-PSRepository. Voulez-vous vraiment installer les modules à
partir de PSGallery ?
[O] Oui  [T] Oui pour tout  [N] Non  [U] Non pour tout  [S] Suspendre  [?] Aide (la valeur par défaut est « N ») : O

Afterwards, I was indeed able to get a sorted output of winget. This solution works fine and is an acceptable workaround. But it is also kind of an overkill, and I hope someone will eventually add the required sorting options to winget

PS C:\Users\jypeter> Get-WinGetPackage | sort name

Name                                          Id                                                Version             Available Source
----                                          --                                                -------             --------- ------
7-Zip                                         7zip.7zip                                         22.01               24.06     winget
Adobe Acrobat XI Pro                          {AC76BA86-1033-FFFF-7760-000000000006}            11.0.23
[...]
XnView                                        XnSoft.XnView.Classic                             2.51.5              2.51.6    winget
Zoom Workplace                                XP99J3KP4XZ4VV                                    6.0.11 (39959)                mss...
Zotero                                        DigitalScholar.Zotero                             6.0.15              6.0.36    winget

jypeter avatar Jun 07 '24 16:06 jypeter

@jypeter,

I'm very sorry for giving bad advice in this thread. It definitely was overkill and I'll avoid doing so in the future.

stephengillie avatar Jun 07 '24 18:06 stephengillie

@stephengillie Do not worry, I think your answer was quite relevant and I have added it to my small winget documentation!

But I do hope some winget developper (@denelon ?) will eventually address the following questions:

  • determine what the current order of winget list is. Note: I have just discovered the WinGet CLI Settings page. I did not have a %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json file and I guess I was really using the default settings. But anyway, this page does not mention anything about sorting
  • change the default order to be sorted by package name. This will make some sense and be useful
  • add sorting options to winget

jypeter avatar Jun 10 '24 13:06 jypeter