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

Is there a Winget Show PowerShell equivalent?

Open jdhitsolutions opened this issue 2 years ago • 6 comments

Description of the new feature / enhancement

The cli tool lets me get package details.

 winget show WestWind.MarkdownMonster
Found Markdown Monster [WestWind.MarkdownMonster]
Version: 3.0.8.0
Publisher: West Wind Technologies
Publisher Url: https://markdownmonster.west-wind.com
Publisher Support Url: https://markdownmonster.west-wind.com/docs/_4s0144w3g.htm
Author: Rick Strahl, West Wind Technologies
Moniker: markdown-monster
Description: MarkdownMonster - A powerful, yet easy to use Markdown Editor for Windows
Homepage: https://markdownmonster.west-wind.com
License: Proprietary
License Url: https://markdownmonster.west-wind.com/purchase#License
Copyright: © Rick Strahl, West Wind Technologies, 2015-2023
Copyright Url: https://markdownmonster.west-wind.com/license.txt
Tags:
  documentation
  editor
  markdown
  weblog
Installer:
  Installer Type: inno
  Installer Url: https://github.com/RickStrahl/MarkdownMonsterReleases/raw/master/v3/v3.0/MarkdownMonsterSetup-3.0.8.exe
  Installer SHA256: 9f0fd832b262a6684a134ad100a2a2e6c4fb227e01c4a3c06af92da735970534

But I can't find a comparable equivalent in the PowerShell module. The find command is limited.

find-wingetpackage WestWind.MarkdownMonster | Select *

Version           : 3.0.8.0
Name              : Markdown Monster
Id                : WestWind.MarkdownMonster
IsUpdateAvailable : False
Source            : winget
AvailableVersions : {3.0.8.0, 3.0.5.0, 3.0.4.0, 3.0.3.0…}

Proposed technical implementation details

Show is a valid verb so you should be able to add Show-Wingetpackage and write a structured object to the pipeline. The command should write a structured object to the pipeline with these properties.

Version: 3.0.8.0
Publisher: West Wind Technologies
Publisher Url: https://markdownmonster.west-wind.com
Publisher Support Url: https://markdownmonster.west-wind.com/docs/_4s0144w3g.htm
Author: Rick Strahl, West Wind Technologies
Moniker: markdown-monster
Description: MarkdownMonster - A powerful, yet easy to use Markdown Editor for Windows
Homepage: https://markdownmonster.west-wind.com
License: Proprietary
License Url: https://markdownmonster.west-wind.com/purchase#License
Copyright: © Rick Strahl, West Wind Technologies, 2015-2023
Copyright Url: https://markdownmonster.west-wind.com/license.txt

Tags should be an array property.

Tags:
  documentation
  editor
  markdown
  weblog

I'd make the Installer property a nested object.

Installer:
  Installer Type: inno
  Installer Url: https://github.com/RickStrahl/MarkdownMonsterReleases/raw/master/v3/v3.0/MarkdownMonsterSetup-3.0.8.exe
  Installer SHA256: 9f0fd832b262a6684a134ad100a2a2e6c4fb227e01c4a3c06af92da735970534

jdhitsolutions avatar Oct 27 '23 16:10 jdhitsolutions

For an unofficial implementation, consider starting with Search-WinGetManifest and replacing a couple of words to arrive at Show-WinGetPackage:

Function Show-WinGetPackage ($term) {
	$out = WinGet show $term --disable-interactivity  #| where {$_ -notmatch "Γûê"}
	return $out 
}

From here, the output could be parsed and modified using Select before return.

stephengillie avatar Oct 27 '23 18:10 stephengillie

I am doing something similar with Get-WGPackage from my WingetTools module.

PS C:\> get-wgpackage -id WestWind.MarkdownMonster | select *


Moniker             : markdown-monster
Description         : MarkdownMonster A powerful, yet easy to use Markdown Editor for Windows
Author              : Rick Strahl, West Wind Technologies
Publisher           : West Wind Technologies
PublisherUrl        : https://markdownmonster.west-wind.com
PublisherSupportUrl : https://markdownmonster.west-wind.com/docs/_4s0144w3g.htm
Homepage            : https://markdownmonster.west-wind.com
Name                : Markdown Monster
ID                  : WestWind.MarkdownMonster
Version             : 3.0.8.0
Source              : winget
Computername        : PROSPERO

I am hoping for a more native solution that doesn't require parsing YAML.

jdhitsolutions avatar Oct 27 '23 21:10 jdhitsolutions

Instead of a new command, you could add the manifest details as a metadata property on the output object. Find-Module does that with an AdditionalMetadata property.

jdhitsolutions avatar Aug 09 '24 18:08 jdhitsolutions

I'm not familiar with the best idiom here.

Get-WinGetPackage is showing the "installed" packages. Find-WinGetPackage is showing what's available in configured sources.

I was wondering if something like adding that to the output of Find-WinGetPackage <PackageId> -Verbose is the right way to do this vs. FindWinGetPackage <PackageId> | Select *.

There is also the interesting caveat with respect to showing available versions which would be likely cause more round trips to the remote source to fetch the versions rather than showing the metadata from the latest version or a particular version that has been specified.

I'll chat with some of the folks on the PowerShell team about this one.

denelon avatar Nov 15 '24 20:11 denelon

If we were to do something like Get-WinGetManifest <Package ID> and display the logically equivalent metadata from winget show <package>. In order to reduce all the extra network round trips, this cmdlet would require the argument to uniquely identify a single package (and version) in order to render some output.

The actual manifest would contain all the localized content as well as the installers for all scopes, so that would be extra metadata in the object that could be expected for a single version of a package.

In theory, then a user could do something like Get-WinGetManifest <PackageId> | Install-WinGetPackage and that would somewhat mirror the behavior of: winget show <package> followed by winget install <package>.

denelon avatar Nov 15 '24 20:11 denelon