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

JSON Formatted Output Support

Open RichiCoder1 opened this issue 5 years ago β€’ 17 comments

Description of the new feature/enhancement

To enable automation and consumption via other tools, it'd be great if current and future commands supported a JSON output mode.

RichiCoder1 avatar May 19 '20 16:05 RichiCoder1

Modern Windows command line apps are in powershell, and already output structured objects. These can already be converted to JSON, Excel, CSV, or whatever other format is preferred.

The issue is that winget is unique, in that it doesn't output any structured data. #196 was created to address this issue but it was closed.

mikemaccana avatar May 23 '20 10:05 mikemaccana

@mikemaccana As mentioned on the other two issues, PowerShell isn't available in all Windows SKUs which this is targeting. For native PowerShell support, you're looking for https://github.com/microsoft/winget-cli/issues/221.

RichiCoder1 avatar May 23 '20 22:05 RichiCoder1

@RichiCoder1 Could you list all target SKUs and/or a link to the requirements spec, please?

megamorf avatar May 23 '20 22:05 megamorf

It's been mentioned multiple times across multiple sources:

  • https://github.com/microsoft/winget-cli/issues/221#issuecomment-632985508
  • https://twitter.com/richturn_ms/status/1262973495559876608?s=20

RichiCoder1 avatar May 23 '20 22:05 RichiCoder1

@RichiCoder1 I'm going through the backlog as a part of our planning exercise for the next few milestones. I'm going to close this as a Duplicate of #221.

denelon avatar Aug 06 '21 17:08 denelon

@RichiCoder1 we've identified this Issue as a duplicate of another one that already exists. This specific instance is being closed in favor of tracking the concern over on the referenced Issue. Thanks for your report! Be sure to add your πŸ‘ to the other issue to help raise the priority.

ghost avatar Aug 06 '21 17:08 ghost

I'm cool with that as long as the ultimate functionality is still flexible enough to be consumed from other tools

RichiCoder1 avatar Aug 06 '21 17:08 RichiCoder1

Yes, that is the intent. Rather than building some kind of --output-JSON flag, the native PowerShell implementation will provide objects that may be used, and will not have the truncated output string behavior currently exhibited in the winget.exe client.

denelon avatar Aug 06 '21 17:08 denelon

Woo native powershell implementation! That’s exactly what I personally wanted.

mikemaccana avatar Aug 06 '21 18:08 mikemaccana

@denelon PowerShell isn't the only Windows shell. For example, I also use nushell, some users use git bash, and some users still use the command prompt.

I strongly hope to implement the json output parameter (like --output-JSON).

stknohg avatar Oct 28 '21 09:10 stknohg

You can turn output from any powershell command into JSON by piping to convertto-JSON

mikemaccana avatar Oct 28 '21 09:10 mikemaccana

I think It feels very wasteful to call powershel.exe or pwsh.exe every time I use winget on non-PowerShell shell.

stknohg avatar Oct 28 '21 09:10 stknohg

I'm going to re-open this issue. It's not high-priority (unless we see a lot of πŸ‘) since we have the option in PowerShell, but I can see value in what is being asked for.

We still have more work to completely move everything the CLI is calling into the COM APIs, and once that's done, providing some kind of output type/format "should" be a bit easier to implement.

denelon avatar Mar 27 '24 21:03 denelon

I'm going to re-open this issue. It's not high-priority (unless we see a lot of πŸ‘) since we have the option in PowerShell, but I can see value in what is being asked for.

We still have more work to completely move everything the CLI is calling into the COM APIs, and once that's done, providing some kind of output type/format "should" be a bit easier to implement.

I'd like to note one thing in reference to powershell. Until the winget powershell module can be used in system context there is a gap in functionality that could be filled if winget output could be json formatted. That would make converting winget output to a powershell object very easy.

Banthaf0dder avatar Apr 09 '24 23:04 Banthaf0dder