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

Is there a Winget Show PowerShell equivalent? #3823

Open jdhitsolutions opened 10 months ago

jdhitsolutions commented 10 months ago

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
stephengillie commented 10 months ago

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.

jdhitsolutions commented 10 months ago

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 commented 1 month ago

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.