Open giggio opened 1 year ago
You might want to give the "Microsoft.WinGet.Client" PowerShell module or look at the COM API in WinGet for automation scenarios.
I'm using the PowerShell module, but it is still incomplete. I need the pins to be available there. I'll check out the COM API. Still, one might need to capture the output, for example, in CI scenarios, and it will produce a lot of unnecessary text.
I just checked out the API, you can't manage pins through it, either. https://github.com/microsoft/winget-cli/blob/master/doc/specs/%23888%20-%20Com%20Api.md
I agree with @giggio. Getting rid of the spinner output using a command line argument would help to get the captured output clean. BTW, the same applies to the download progress output IMO. TBH I would expect all this output suppressed when using a the /silent switch.
And no, switching to the PowerShell module or using the COM API is no option for me. The automation script works as it is. It's just tooooo noisy!
[Policy] Area-Output
The spinners should always be disabled when --disable-interactivity
parameter is specified by the user.
If interactive features are explicitly disabled, there is absolutely no reason to print spinners, which are a purely interactive feature.
Here's my current workaround to skip spinners, progress bars and blank lines:
# patterns to omit in output
$spinners = '\', '/', '|', '-' | ForEach-Object { "^\s*\$_\s*`$" } | Join-String -Separator '|'
$progressBars = '█', '▒' | ForEach-Object { "^.+\$_.+`$" } | Join-String -Separator '|'
$blankLine = '^\s*$'
$skip = "$spinners|$progressBars|$blankLine"
winget upgrade `
--all `
--accept-source-agreements `
--accept-package-agreements `
--silent `
--disable-interactivity `
| Select-String -NotMatch $skip
I did something similar but replaced the characters instead of using Select-String
so that the output could be viewed in real-time...
https://gist.github.com/asheroto/96bcabe428e8ad134ef204573810041f
My solution for lists and tables so far was to look for the separator line (--------------
) and trim everything before it +/- 1 line (in some scripts I need to parse the headers, since winget list, for example, can produce a different number of columns). But you always get the line.
$output = WinGet.exe $params
$lineNumber = $output.IndexOf($output -match '----+') - 2 #-2 returns the header line. W/o -2 you get all past the separator line
if ($lineNumber -lt 0) { return $null}
return $output[$lineNumber..($output.Length-1)]
To make matter worse, when the output is captured in a string, you get encoding issues and skewed columns
Here's an example of winget list
- check the Inter Graphics Command Center name and id
We need --disable-interactivity
to properly handle all this
Name Id Version Available Source
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
LogiOptionsWordAddin 2C559D7A6B8C383AF1FC7ED06D375EAC624F143E6F778C4FCDD50D9E023A4354 10.10.4.0
Tag Explorer 46887Dr.Cooper.TagExplorer_s0pf5z833f2vc 3.7.0.0
Ritt 62283Ritt.Ritt_qr54r3v2h1vqw 1.4.0.0
Visual Studio Enterprise 2022 Microsoft.VisualStudio.2022.Enterprise 17.9.6 winget
LogiOptionsExcelAddin 67C3222594B96ED78A8AA3050861B9C717ACC01FF3F90093DB70B6D61707DA57 10.10.4.0
LogiOptionsPowerPointAddin 75B10E1044297ED2ACEE0B524BDF62C55A10D7609038BE3D371ABA95D4F4DA6F 10.10.4.0
Intel® Graphics Command Center AppUp.IntelGraphicsExperience_8j3eq9eme6ctt 1.100.5435.0
ThunderboltTM Control Center AppUp.ThunderboltControlCenter_8j3eq9eme6ctt 1.0.37.0
\
|
Name Id Version Available Source
-----------------------------------------------------------------------------------------------------------------------
LogiOptionsWordAddin 2C559D7A6B8C383AF1FC7ED06D375EAC624F143… 10.10.4.0
Tag Explorer 46887Dr.Cooper.TagExplorer_s0pf5z833f2vc 3.7.0.0
Ritt 62283Ritt.Ritt_qr54r3v2h1vqw 1.4.0.0
Visual Studio Enterprise 2022 Microsoft.VisualStudio.2022.Enterprise 17.9.6 winget
LogiOptionsExcelAddin 67C3222594B96ED78A8AA3050861B9C717ACC01… 10.10.4.0
LogiOptionsPowerPointAddin 75B10E1044297ED2ACEE0B524BDF62C55A10D76… 10.10.4.0
Intel® Graphics Command Center AppUp.IntelGraphicsExperience_8j3eq9eme… 1.100.5435.0
ThunderboltTM Control Center AppUp.ThunderboltControlCenter_8j3eq9em… 1.0.37.0
Description of the new feature / enhancement
Add an option to disable the spinner and any other progress indicator. This adds clutter to the screen if you are trying to capture what happened, and makes it harder to process winget output with command line tools.
Proposed technical implementation details
Add an option to the settings.json file.