commit 36d4495115c5cb1b112b2f6d48440eca2e9133ea
parent 6683dbe12382c8b5ecd01796085436c19c624bd5
Author: Kaleb Luedtke <jluedtk@jci.com>
Date: Tue, 24 Jan 2023 22:01:15 -0600
Allow Version Listing through 'Winget Search' (#2847)
Diffstat:
5 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/src/AppInstallerCLICore/Commands/SearchCommand.cpp b/src/AppInstallerCLICore/Commands/SearchCommand.cpp
@@ -25,6 +25,7 @@ namespace AppInstaller::CLI
Argument::ForType(Execution::Args::Type::Exact),
Argument::ForType(Execution::Args::Type::CustomHeader),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
+ Argument::ForType(Execution::Args::Type::ListVersions),
};
}
@@ -78,8 +79,21 @@ namespace AppInstaller::CLI
context <<
Workflow::OpenSource() <<
Workflow::SearchSourceForMany <<
- Workflow::HandleSearchResultFailures <<
- Workflow::EnsureMatchesFromSearchResult(false) <<
- Workflow::ReportSearchResult;
+ Workflow::HandleSearchResultFailures;
+
+ if (context.Args.Contains(Execution::Args::Type::ListVersions))
+ {
+ context <<
+ Workflow::EnsureOneMatchFromSearchResult(false) <<
+ Workflow::ReportPackageIdentity <<
+ Workflow::ShowAppVersions;
+ }
+ else
+ {
+ context <<
+ Workflow::EnsureMatchesFromSearchResult(false) <<
+ Workflow::ReportSearchResult;
+ }
+
}
}
diff --git a/src/AppInstallerCLICore/Workflows/ShowFlow.cpp b/src/AppInstallerCLICore/Workflows/ShowFlow.cpp
@@ -224,16 +224,4 @@ namespace AppInstaller::CLI::Workflow
table.OutputLine({ manifest.Version, manifest.Channel });
table.Complete();
}
-
- void ShowAppVersions(Execution::Context& context)
- {
- auto versions = context.Get<Execution::Data::Package>()->GetAvailableVersionKeys();
-
- Execution::TableOutput<2> table(context.Reporter, { Resource::String::ShowVersion, Resource::String::ShowChannel });
- for (const auto& version : versions)
- {
- table.OutputLine({ version.Version, version.Channel });
- }
- table.Complete();
- }
}
\ No newline at end of file
diff --git a/src/AppInstallerCLICore/Workflows/ShowFlow.h b/src/AppInstallerCLICore/Workflows/ShowFlow.h
@@ -28,10 +28,4 @@ namespace AppInstaller::CLI::Workflow
// Inputs: Manifest
// Outputs: None
void ShowManifestVersion(Execution::Context& context);
-
- // Shows all versions for an application.
- // Required Args: None
- // Inputs: SearchResult [only operates on first match]
- // Outputs: None
- void ShowAppVersions(Execution::Context& context);
}
\ No newline at end of file
diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp
@@ -1111,6 +1111,18 @@ namespace AppInstaller::CLI::Workflow
{
context.SetExecutionStage(m_stage);
}
+
+ void ShowAppVersions(Execution::Context& context)
+ {
+ auto versions = context.Get<Execution::Data::Package>()->GetAvailableVersionKeys();
+
+ Execution::TableOutput<2> table(context.Reporter, { Resource::String::ShowVersion, Resource::String::ShowChannel });
+ for (const auto& version : versions)
+ {
+ table.OutputLine({ version.Version, version.Channel });
+ }
+ table.Complete();
+ }
}
AppInstaller::CLI::Execution::Context& operator<<(AppInstaller::CLI::Execution::Context& context, AppInstaller::CLI::Workflow::WorkflowTask::Func f)
diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.h b/src/AppInstallerCLICore/Workflows/WorkflowBase.h
@@ -368,6 +368,12 @@ namespace AppInstaller::CLI::Workflow
// Outputs: InstalledPackageVersion
void GetInstalledPackageVersion(Execution::Context& context);
+ // Shows all versions for an application.
+ // Required Args: None
+ // Inputs: SearchResult [only operates on first match]
+ // Outputs: None
+ void ShowAppVersions(Execution::Context& context);
+
// Reports execution stage in a workflow
// Required Args: ExecutionStage
// Inputs: ExecutionStage?