Skip to content
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

Enhancements to list command #1155

Open
denelon opened this issue Jun 11, 2021 · 14 comments
Open

Enhancements to list command #1155

denelon opened this issue Jun 11, 2021 · 14 comments
Labels
Command-List Issue related to WinGet List Issue-Feature This is a feature request for the Windows Package Manager client.
Milestone

Comments

@denelon
Copy link
Contributor

denelon commented Jun 11, 2021

Description of the new feature/enhancement

The winget list command was designed to display all packages installed on a users Windows 10 machine in Add / Remove Programs (ARP). The command would also show which Apps with possible upgrades were available from sources configured in the Windows Package Manager. This specification proposes enhancements to the output provided by the list command.

Proposed technical implementation details (optional)

Modify the output behavior for winget list to display available version from any source. When a package is available via more than once source, the first configured source should be displayed.

Affected by:

Note: Users will be able to see if packages are available from individual sources by specifying the source as an argument to the list command.

Modify the output behavior for winget list -s <source> to display only packages available from the specified source.

Add a new argument -u, --unavailable to the list command to display Apps installed in Windows Apps & Features not matching any configured source.

@denelon denelon added the Issue-Feature This is a feature request for the Windows Package Manager client. label Jun 11, 2021
@ghost ghost added the Needs-Triage Issue need to be triaged label Jun 11, 2021
@denelon
Copy link
Contributor Author

denelon commented Jun 11, 2021

@denelon denelon removed the Needs-Triage Issue need to be triaged label Jun 11, 2021
@jedieaston
Copy link
Contributor

the first configured source should be displayed.

Why not the highest version available? If I have multiple sources and one is kept more up-to-date than another, I'd want to see that instead (as a reason people add multiple sources is often because one is more maintained than another).

@jdhitsolutions
Copy link

This looks like the right place to add instead of opening a new issue. The List parameter needs to have additional logic that only shows me packages installed by Winget. In fact, I think that should be the default. Give me a --all switch to show all possible apps. Although I'm not sure what good it does to see a package like Microsoft.BingWeather_8wekyb3d8bbwe in the List output when winget can't really do anything with it.

@denelon
Copy link
Contributor Author

denelon commented Aug 30, 2021

Users can still "uninstall" packages regardless of how they were installed.

It's also possible for a user to install a version with the Windows Package Manager, and then upgrade/downgrade it manually. We do have additional complexity to handle when a package is available in more than one source.

@denelon denelon modified the milestones: v1.3-Client, v.Next-Client Mar 11, 2022
@pluto-dev
Copy link

Is it possible to add issue #1653 to the list of enhancements. I would greatly appreciate this.

@ackalker
Copy link

ackalker commented Apr 8, 2023

I see that there are multiple issues about winget list --source <source> not filtering the results by <source>. All of these issues were closed as duplicates of the current issue, but meanwhile the problem remains.

Is there anyone working on an actual fix?

@ItzLevvie
Copy link

ItzLevvie commented Apr 8, 2023

Is there anyone working on an actual fix?

@ackalker: Please add your thumbs up (👍) to this issue so that it can be prioritized.

@mavaddat
Copy link

mavaddat commented Jun 4, 2023

Although it's not perfect, I have created a function Get-WingetLogs to parse and query the winget logs. It allows searching the logs by string or date boundaries. It also allows highlighting local system paths to make the log messages easier to read.

@Trenly
Copy link
Contributor

Trenly commented Jun 16, 2023

[Policy] Command-List

@microsoft-github-policy-service microsoft-github-policy-service bot added the Command-List Issue related to WinGet List label Jun 16, 2023
@klezm
Copy link

klezm commented Jun 28, 2023

To sort the winget list output I wrote 2 small scripts for powershell.

This one-liner will sort the output alphabetically.
This will overwrite the variable $wg if defined. To prevent this use a script block: The call operator & executes the following script block {...} which prevents the variable $wg to be persistent.
If the output includes progress bars just rerun the command.

$wg = winget list; $wg[0..3]; $wg[4..($wg.Length-1)] | Sort-Object
# Or inside a script block
& { $wg = winget list; $wg[0..3]; $wg[4..($wg.Length-1)] | Sort-Object }

This will parse the output of winget list and return a table you can sort as you wish. For sorting use the command Sort-Object as shown in the last two lines.

# Get the output of winget list
$wgRaw = winget list # -n 15

# Length of longest line
$lengthMax = $wgRaw | ForEach-Object { $_.Length } | measure -Maximum | Select-Object -ExpandProperty Maximum
# Index of the header line
$header_index = $wgRaw.IndexOf(($wgRaw | Where-Object { $_ -match "^-{" + ($lengthMax - 2) + "}" })) - 1
# Remove all lines before the header line (removes progress bars)
$wglist = $wgRaw[$header_index..($wgRaw.Length - 1)]
# $wglist.GetType(); $wglist | ForEach-Object { $_.GetType() } | Get-Unique

# Column names
$col_names = $wglist[0] -split '\s+'
# Column indices (start index of each column)
$ci = ($col_names | ForEach-Object { $wglist[0].IndexOf($_) }) # + $lengthMax
# Column widths
$cw = 0..($ci.Length - 1) | ForEach-Object { $ci[$_ + 1] - $ci[$_] }

# Match blocks of any characters with the lengths given in $cw
$regex = "^" + (($cw[0..($cw.Length - 2)] | ForEach-Object { "(.{$_})" }) -join "") + "(.*)$" # { "(.{" + ($_ - 1) + "})" }) -join " " # Include spaces between columns
# Replacement string with the blocks separated by "|"
$replace = (0..($col_names.Length - 1) | ForEach-Object { '$' + ($_ + 1) + "" }) -join "|"

# Convert fixed length lines into "|" separated lines
$wglist = $wglist | ForEach-Object { $_.PadRight($lengthMax) -replace $regex, $replace }
# Trim whitespaces of all values
$wglist = $wglist | ForEach-Object { $_ -replace " *" + "|" + " *", "|" }

# Parse CSV
$wglist = $wglist[2..($wglist.Length - 1)] | ConvertFrom-Csv -Delimiter "|" -Header $col_names # | ForEach-Object { $_.Trimend() }

# Sort and print as table

# Because of different locales better use $col_names values: $col_names = "Name","Id","Version","Available","Source"
$wglist | Sort-Object -Property @{Expression = $col_names[4]; Descending = $true},$col_names[0] | Format-Table # -GroupBy $col_names[4]

# Filter where Source is winget
# $wglist | Sort-Object -Property $col_names[4],$col_names[0] | Where-Object { $_.Quelle -eq "winget" } | Format-Table

Because I had some encoding problems I had to set the encoding in the powershell (see: stackoverflow.com)

$OutputEncoding = [System.Text.Encoding]::UTF8 # Sets the encoding for e.g. | and/or communication between programs and/or processes
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # Sets the encoding for STDOUT and the console/terminal output

@Limyx826
Copy link

After 2 years this still isn't solved.

@GNITOAHC
Copy link

I see that there are multiple issues about winget list --source <source> not filtering the results by <source>. All of these issues were closed as duplicates of the current issue, but meanwhile the problem remains.

Is there anyone working on an actual fix?

I temporarily use winget list | Select-String "winget" to filter.

@mdanish-kh
Copy link
Contributor

I see that there are multiple issues about winget list --source <source> not filtering the results by <source>. All of these issues were closed as duplicates of the current issue, but meanwhile the problem remains.
Is there anyone working on an actual fix?

I temporarily use winget list | Select-String "winget" to filter.

Have you tried using the WinGet PowerShell module? Get-WinGetPackage is the equivalent command for winget list. Since many comments mention sorting as well, you can pipe its output to Sort-Object.

Get-WinGetPackage | Where-Object {($_.Source -eq 'winget')} | Sort-Object Name

While I understand this issue primarily pertains to achieving these functionalities within the CLI output, I wanted to mention the PowerShell module (since it hasn't been referenced here) as a potential solution that might fulfill someone's needs.

Note: Currently the PowerShell module only works on PowerShell 7 MSI

@CanePlayz
Copy link

That would be quite useful to see which of my installed apps have a corresponding winget manifest and get recognized by winget properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-List Issue related to WinGet List Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

No branches or pull requests