winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 36b0a236a0da48c61e7778e8fce994c858f01625
parent b1979614e4e0e75bcaf04d082de4c19d442dc8ca
Author: Kaleb Luedtke <trenlymc@gmail.com>
Date:   Thu, 27 Apr 2023 11:46:40 -0400

Add argument to list only upgradeable (#3162)

* Add argument to list only upgradeable

* Update src/AppInstallerCLICore/Argument.cpp

Co-authored-by: yao-msft <50888816+yao-msft@users.noreply.github.com>

---------

Co-authored-by: yao-msft <50888816+yao-msft@users.noreply.github.com>
Diffstat:
Msrc/AppInstallerCLICore/Argument.cpp | 5+++++
Msrc/AppInstallerCLICore/Commands/ListCommand.cpp | 3++-
Msrc/AppInstallerCLICore/ExecutionArgs.h | 3+++
Msrc/AppInstallerCLICore/Resources.h | 1+
Msrc/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 3+++
5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/AppInstallerCLICore/Argument.cpp b/src/AppInstallerCLICore/Argument.cpp @@ -158,6 +158,11 @@ namespace AppInstaller::CLI case Execution::Args::Type::ListVersions: return { type, "versions"_liv }; + // List command + case Execution::Args::Type::Upgrade: + return { type, "upgrade-available"_liv}; + + // Pin command case Execution::Args::Type::GatedVersion: return { type, "version"_liv, 'v', ArgTypeCategory::None, ArgTypeExclusiveSet::PinType }; diff --git a/src/AppInstallerCLICore/Commands/ListCommand.cpp b/src/AppInstallerCLICore/Commands/ListCommand.cpp @@ -26,6 +26,7 @@ namespace AppInstaller::CLI Argument{ Execution::Args::Type::InstallScope, Resource::String::InstalledScopeArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help }, Argument::ForType(Execution::Args::Type::CustomHeader), Argument::ForType(Execution::Args::Type::AcceptSourceAgreements), + Argument{ Execution::Args::Type::Upgrade, Resource::String::UpgradeArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help }, }; } @@ -80,6 +81,6 @@ namespace AppInstaller::CLI Workflow::SearchSourceForMany << Workflow::HandleSearchResultFailures << Workflow::EnsureMatchesFromSearchResult(OperationType::List) << - Workflow::ReportListResult(); + Workflow::ReportListResult(context.Args.Contains(Execution::Args::Type::Upgrade)); } } diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h @@ -92,6 +92,9 @@ namespace AppInstaller::CLI::Execution // Show command ListVersions, // Used in Show command to list all available versions of an app + // List Command + Upgrade, // Used in List command to only show versions with upgrades + // Pin command GatedVersion, // Differs from Version in that this supports wildcards BlockingPin, diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h @@ -506,6 +506,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(UpdateNotApplicableReason); WINGET_DEFINE_RESOURCE_STRINGID(UpdateNoPackagesFound); WINGET_DEFINE_RESOURCE_STRINGID(UpdateNoPackagesFoundReason); + WINGET_DEFINE_RESOURCE_STRINGID(UpgradeArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeAvailableForPinned); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeBlockedByPinCount); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeCommandLongDescription); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1477,6 +1477,9 @@ Please specify one of them using the --source option to proceed.</value> <data name="IncompatibleArgumentsProvided" xml:space="preserve"> <value>Incompatible command line arguments provided</value> </data> + <data name="UpgradeArgumentDescription" xml:space="preserve"> + <value>Lists only packages which have an upgrade available</value> + </data> <data name="UpgradeAvailableForPinned" xml:space="preserve"> <value>The following packages have an upgrade available, but require explicit targeting for upgrade:</value> <comment>"require explicit targeting for upgrade" means that the package will not be upgraded with all others unless an extra flag is added, or the package is mentioned explicitly</comment>