Skip to content
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

winget support #500

Closed
dinhanhx opened this issue Mar 12, 2022 · 12 comments
Closed

winget support #500

dinhanhx opened this issue Mar 12, 2022 · 12 comments
Labels
🎁 feature request Not existing yet and need to be implemented 📦 manager: winget winget 🖥 platform: Windows Windows

Comments

@dinhanhx
Copy link

WinGet is a new native tool in Windows 11.

@kdeldycke kdeldycke added the 🎁 feature request Not existing yet and need to be implemented label Mar 12, 2022
@kdeldycke kdeldycke added the 🙏 help wanted I can't do this alone and need contributors label Apr 25, 2022
@autinerd
Copy link
Contributor

I looked at it and the parsing would currently be a bloody mess. The tool is currently only designed to be used interactively in a terminal.

There are some issues already in discussion to allow machine-readable outputs, but until that the parsing is too complicated, because winget creates a table with dynamic-sized columns, which is even with sed etc. not too trivial.

microsoft/winget-cli#221
microsoft/winget-cli#2032

I would put it on hold until winget offers a better experiance for parsing.

@dinhanhx
Copy link
Author

Alright let's wait then

@kdeldycke
Copy link
Owner

kdeldycke commented Jun 26, 2022

Parsing table with variable columns is doable. Look for instance how other package managers does it:

  • emerge:
    ► emerge --update --deep --pretend --columns --color n --nospinner @world
    [blocks B ] app-text/dos2unix
    [ebuild N ] app-games/qstat [25c]
    [ebuild R ] sys-apps/sed [2.4.7-r6]
    [ebuild U] net-fs/samba [2.2.8_pre1] [2.2.7a]
    [ebuild U] sys-devel/distcc [2.16] [2.13-r1] USE=ipv6* -gtk
    [ebuild r U] dev-libs/icu [50.1.1:0/50.1.1] [50.1-r2:0/50.1]
    [ebuild r R ] dev-libs/libxml2 [2.9.0-r1:2] USE=icu
  • flatpak:
    ► flatpak list --app --columns=name,application,version \
    > --ostree-verbose
    Name Application ID Version
    Peek com.uploadedlobster.peek 1.3.1
    Fragments de.haeckerfelix.Fragments 1.4
    GNOME MPV io.github.GnomeMpv 0.16
    Syncthing GTK me.kozec.syncthingtk v0.9.4.3
    Builder org.flatpak.Builder

I can try to implement a first version and we can collectively iterate on it. The thing is I do not have any Windows instance available at the moment. But if you provide me with terminal captures of some commands I can make an attempt.

Does WinGet allows you to list installed/outdated packages? That might be a start.

@kdeldycke kdeldycke changed the title Add WinGet for Windows winget support Jul 12, 2022
@hannesdelbeke
Copy link

hannesdelbeke commented Feb 26, 2023

might be relevant, 3rd party module adding winget support to powershell https://github.com/ethanbergstrom/Cobalt
output of list is the same though so don't think it solves the parsing

@hannesdelbeke
Copy link

seems there is now official powershell support that supports custom output

@halr9000 we've just released a native PowerShell module. It provides structured output.

however when looking at the repo, the list command doesn't seem to be in there

Get-WinGetVersion
Enable-WinGetSetting
Disable-WinGetSetting
Add-WinGetSource
Remove-WinGetSource
Reset-WinGetSource
Find-WinGetPackage
Get-WinGetPackage
Get-WinGetSource
Install-WinGetPackage
Uninstall-WinGetPackage
Update-WinGetPackage

@halr9000
Copy link

halr9000 commented Feb 26, 2023

@hannesdelbeke Not sure precisely what you mean but I would expect a list action to correspond to the get verb.

So, Get-WingetPackage

Does that help?

@hannesdelbeke
Copy link

@hannesdelbeke Not sure precisely what you mean but I would expect a list action to correspond to the get verb.
So, Get-WingetPackage
Does that help?

yes it seems that Get-WingetPackage lists all installed packages, just like winget list.
I was confused since I expected the commands to be named the same.

Do you perhaps also know if there is an option to get machine readable output from Get-WingetPackage?
e.g. output comma separated, or a json or yaml.

@halr9000
Copy link

halr9000 commented Feb 27, 2023

yes it seems that Get-WingetPackage lists all installed packages, just like winget list. I was confused since I expected the commands to be named the same.

Oh! Actually, what they did is very powershelly of them, I like it. :) PowerShell has a strongly encouraged (but ultimately. optional) set of approved verbs. You can also list them, along with definitions by executing Get-Verb. Same is true for parameters. For this reason, anyone who understands PowreShell well, would never expect a "straight port", as that would ruin one of the key principles of the language, which is consistency. For more, I would read the Monad Manifesto, or search for interviews of Jeffrey Snover on why he and the team created the language. (There's at least one of me interviewing him on PowerScripting Podcast many years ago.)

Do you perhaps also know if there is an option to get machine readable output from Get-WingetPackage? e.g. output comma separated, or a json or yaml.

Yup, checked just now, and the winget team did good here as well. Another principle: "everything is an object". Because the cmdlet returns an object and not an array of strings, you can do cool stuff like convert it to JSON in a consistent fashion like you would with any other object:

PS > Get-WinGetPackage python | ConvertTo-Json
[
  {
    "ID": "Miniconda3 py39_4.10.3 (Python 3.9.5 64-bit)",
    "Version": "394.10.3",
    "Source": ""
  },
  {
    "ID": "Python.Python.3.10",
    "Version": "3.10.9",
    "Source": "winget"
  },
  {
    "ID": "SomePythonThings.WingetUIStore",
    "Version": "1.6.1",
    "Source": "winget"
  }
]

As far as YAML goes, looks like there's a module for that. CSV is built-in like JSON, try convertto-csv.

@kdeldycke
Copy link
Owner

Wow, thanks @hannesdelbeke and @halr9000 for keeping track of these new developments! I'm not a Windows user so I'm slow picking up new development. I'll try to take a look at it at one point, but if you think there's enough material to attempt an implementation, feel free to start a PR. Even if it's janky or hackish, it can serve as a good starting point to iterate on.

At the moment I'm deep into refactoring and stabilizing the test suite of mpm and that's my only focus so far. And fixing my deeply broken blog. After all of that I might revisit this issue.

@autinerd
Copy link
Contributor

Ah, perfect, thanks @hannesdelbeke and @halr9000! I could do an implementation in the next days.

@kdeldycke
Copy link
Owner

@autinerd If you try an implementation go ahead! I'm not going to nitpick your code anyway, there lots of automatic fix implemented right now by the way of GitHub actions.

@kdeldycke
Copy link
Owner

WinGet has been implemented upstream. It will be available in the upcoming v5.16.0 release of Meta Package Manager.

@kdeldycke kdeldycke added 📦 manager: winget winget and removed 🙏 help wanted I can't do this alone and need contributors labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎁 feature request Not existing yet and need to be implemented 📦 manager: winget winget 🖥 platform: Windows Windows
Projects
None yet
Development

No branches or pull requests

5 participants