-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoiding truncating search/list result #1653
Comments
I'd like an option resulting in behavior similar to PowerShell's See #2161 |
This would be solved by #1753 To use the functionality of PowerShells' 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. |
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? |
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". winget-cli/src/AppInstallerCLICore/TableOutput.h Lines 13 to 30 in 741955e
|
I know that Bill Gates never said the apocryphal quote, but I can't help myself: 120 columns ought to be Enough for Anyone! |
What needs to be done to fix this? I am happy to help with the code. This is unbearable. |
@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 thanks for the suggestion, I prefer the output of |
this is the (powershell) way |
Indeed, that's going the right / PowerShell way. But when you come from the ![]() |
[Policy] Area-Output |
"No one will ever need more than 640K ram" - Bill Gates, 1981 |
Actually, not Bill Gates. |
i don't have Get-WinGetPackage in Windows 10 22H2, where do I get it ? |
Install-Module -Name Microsoft.WinGet.Client https://www.powershellgallery.com/packages/Microsoft.WinGet.Client |
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 |
This doesn't work on my testing machine. (I get the same truncated output with max 120 chars.) Did you maybe change any settings or environment variables? What I found is that the command
formats the output to the maximal size of the console window. Up to 163 characters on my testing machine. So the omitted parts are obviously not just gone. But I can't find a way to catch all the output in a file or variable. |
You are right. Thanks for the hint. It works in PowerShell 7.4.3, it doesn't in 5.1.19041.4648 Thanks to all of you. |
I still wish that was right in PS, so it could be reliably used for scripting on other people's computers. |
Get-WinGetPackage | Format-Table -AutoSize (if terminal window is wide enough OR output to file using "| Out-File -Width 500 -FilePath winget_packages_$env:COMPUTERNAME.txt") are working fine on "PowerShell 7.5.0-preview.3". Still wish this would have been default behaviour in "winget list" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Writing lik€ thi$ do€$ not h€lp your cau$€, pal. |
As it seems to be really difficult to just not truncate the piped output of "winget list", can we please change the constant 120 to 255 or 65535 or anything else not completely too small? |
The most obvious difference to "winget list" is the usage of three ASCII-dots "..." instead of an Unicode-ellipsis "…". The output is truncated anyway and I have a bad feeling because I had to install third-party-software from a source flagged as being unsecure. PS get-host says I am using Powershell version 5.1.19041.4648 although all Windows updates have been installed. |
PowerShell 7 is not an "update to Windows PowerShell 5.1" but kind of a "different product" that installs side-by-side and is not part of Windows (yet 😝). |
Thank you, my old cmd file finally works as expected :-) echo y|pwsh -c "install-Module Microsoft.WinGet.Client" |
@denelon @Trenly, (adding #3071 too) whats the latest update on this? |
It should allow output in json or something... |
@mm6502 |
@jantari |
But you're assuming |
@jantari |
I've been able to rely on winget being present on all new installs when I deploy systems, it's been shipping with windows for a while now... (And even Win Server 2025 seems will ship with it) |
Hey, that wasn't me 😅 But we're bringing up a good point - why isn't the PowerShell module also preinstalled just like winget itself is? Many issues like this one show that the old DOS CLI just doesn't work for people.
Unfortunately, only with the "Desktop Experience" installation. See the announcement and this issue. |
I just added a comment to the issue discussing the need for textual structured output, here: #1753 Most of it applies in this context, so I'll just paste most of what I typed over there: I agree with the need for both JSON and CSV output, as well as simply providing arbitrarily wide text output which can be redirected to a file. The original design philosophy of PowerShell included the ability to flexibly integrate other text-based command line tools seamlessly. Using PowerShell modules and .NET objects everywhere is NOT "the PowerShell way", it is just part of the PowerShell way. A bespoke PowerShell module seems goofy when the winget CLI already does everything that I need it to do. Almost everything, that is. The winget CLI provides for all my needs, as long as I'm sitting in front of the console, watching what's printed after each command. I can widen my terminal and get full output. But try to redirect the perfectly good output to a file? Winget deliberately defeats me by truncating the strings, and now I discover that the project defies user requests to provide some sort of simple text output, which we could then pipe into whatever other tooling we might be needing to interact with. Another scenario: sometimes I need to run winget in a cmd.exe session in a legacy console host. For instance, when I want to upgrade Windows Terminal and/or PowerShell 7.x itself. It makes things much less confusing when the items I'm upgrading aren't running at all. It looks like one might be able to direct their attention to this portion of the code:
|
Description of the new feature / enhancement
Currently, result of
winget list
andwinget 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
The text was updated successfully, but these errors were encountered: