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

avoiding truncating search/list result

Open itn3000 opened this issue 3 years ago • 36 comments

Description of the new feature / enhancement

Currently, result of winget list and winget search is truncated for adjusting display size or 120 chars if output is redirected. This causes the inconvenient which cannot be display full name,id,tags of apps which has long one(eg. Visual Studio family). It cannot be avoided even if result is redirected to file because max width is currently hard coded to 120 in source if redirect.

So I'm glad if options which set max width or getting no truncated string is added(or output with another structured format like json,csv,xml?).

Proposed technical implementation details

No response

itn3000 avatar Oct 28 '21 04:10 itn3000

I'd like an option resulting in behavior similar to PowerShell's Format-Table -AutoSize i.e. don't truncate anything, which requires computing widths based on the widest value for each and every field.

See https://github.com/microsoft/winget-cli/issues/2161

sba923 avatar Aug 31 '22 12:08 sba923

This would be solved by https://github.com/microsoft/winget-cli/issues/1753

To use the functionality of PowerShells' Format-Table -AutoSize I would suggest using the winget PowerShell cmdlets and then just running the actual Format-Table -AutoSize cmdlet. I don't think this has to be re-implemented in the winget CLI. The winget CLI will never have feature parity with all of PowerShells' built-in filtering, sorting and formatting capabilities.

The only open issue here is that output is truncated to a width of 120 characters when redirected to a file. I don't see the reason for that, textfiles don't care about the length of the lines stored in them. But maybe there is a good reason.

jantari avatar Jan 07 '23 23:01 jantari

Indeed, a change where the truncation is removed when output is redirected (to a file, to a pipe) would IMVHO be the best solution.

@denelon what do you think?

sba923 avatar Jan 21 '23 08:01 sba923

We're working on rich PowerShell objects currently, so I would also suggest focusing the attention on the new cmdlets at this time.

WinGet defaults to 120 columns if it cannot get the value from the "consoleInfo". The top 50 lines of output are considered for formatting the table.

https://github.com/microsoft/winget-cli/blob/741955e48ce2f069ab323f71e40dd1326654e7ab/src/AppInstallerCLICore/TableOutput.h#L13-L30

denelon avatar Jan 23 '23 22:01 denelon

WinGet defaults to 120 columns if it cannot get the value from the "consoleInfo". The top 50 lines of output are considered for formatting the table.

I know that Bill Gates never said the apocryphal quote, but I can't help myself:

120 columns ought to be Enough for Anyone! /s :)

halr9000 avatar Feb 06 '23 22:02 halr9000

What needs to be done to fix this? I am happy to help with the code. This is unbearable.

g0t4 avatar May 19 '23 21:05 g0t4

@g0t4 I think the PowerShell module helps in this case tremendously, but from a CLI perspective, I'd think about an argument and setting pair. Naming things is hard, but I could imagine "--no-truncate" & "--truncate" as arguments with a default setting of "truncate" that can be overridden via the CLI and an optional setting for "don't truncate" that can be overriddent via the CLI.

We could also make the "default" width a variable that consumes from an argument and settings.

Another option to consider is an "--output-width" with a value and corollary settings.

denelon avatar May 19 '23 21:05 denelon

@denelon thanks for the suggestion, I prefer the output of Get-WinGetPackage given I can customize that with my own formatting

g0t4 avatar Jun 06 '23 19:06 g0t4

@denelon thanks for the suggestion, I prefer the output of Get-WinGetPackage given I can customize that with my own formatting

this is the (powershell) way

halr9000 avatar Jun 12 '23 09:06 halr9000

@denelon thanks for the suggestion, I prefer the output of Get-WinGetPackage given I can customize that with my own formatting

Indeed, that's going the right / PowerShell way.

But when you come from the winget CLI tool, discoverability is, er... far from obvious:

image

sba923 avatar Jun 12 '23 20:06 sba923

[Policy] Area-Output

Trenly avatar Jun 16 '23 04:06 Trenly

"No one will ever need more than 640K ram" - Bill Gates, 1981

Fred-IV avatar Jul 11 '23 05:07 Fred-IV

Actually, not Bill Gates.

dertuxmalwieder avatar Jul 11 '23 15:07 dertuxmalwieder

i don't have Get-WinGetPackage in Windows 10 22H2, where do I get it ?

josesa-xx avatar Jul 09 '24 05:07 josesa-xx

@josesa-xx

Install-Module -Name Microsoft.WinGet.Client

https://www.powershellgallery.com/packages/Microsoft.WinGet.Client

jantari avatar Jul 09 '24 15:07 jantari

Thanks for the suggestion I was able to get a full list without truncation with command:

Get-WinGetPackage | Format-Table -AutoSize | Out-File -Width 500 -FilePath winget_packages_$env:COMPUTERNAME.txt

josesa-xx avatar Jul 10 '24 18:07 josesa-xx