Add JSON format for list outputs#6346
Conversation
|
I don't think this implementation would scale well for extending it to the rest of the flows. As it is, any time we did any output, we would have to add a check for if we want JSON and do something different. I would prefer this to be handled in the Maybe we should write a spec for this. Just to think out loud about what I think we could do for the implementation...
|
|
Is there a reason the Microsoft.WinGet.Client PowerShell module isn't suitable for JSON output? I know several folks would like JSON output for WinGet, but generally that is because they want to build something that can use the JSON output like an API. We do have COM APIs, and we built the PowerShell module that is likely a better candidate for structured JSON output. |
📖 Description
Adds
--format jsonsupport for package listing output.This enables machine-readable output for:
winget list --format jsonwinget upgrade --format jsonwhen used in list-only modeThe default table output is unchanged.
The JSON output includes installed package fields that match the existing list and upgrade table data, including package name, id, installed version, available version, and source. It also keeps JSON parseable for empty results and common error paths such as source-open failures, WinGet policy blocks, and generic execution failures.
winget upgrade --format jsonis intentionally limited to non-mutating upgrade listing. Commands such aswinget upgrade --all --format jsonare rejected so package installation progress is not mixed with structured output.🔗 References
Related to #1753.
🔍 Validation
Added focused test coverage for:
--format json --help--detailswith JSON list outputRan the focused
AppInstallerCLITestsscenarios for the JSON list and upgrade flows locally.✅ Checklist
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow