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

Allow Version Listing through 'Winget Search' #2847

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/AppInstallerCLICore/Commands/SearchCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -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;
}

}
}
12 changes: 0 additions & 12 deletions src/AppInstallerCLICore/Workflows/ShowFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
6 changes: 0 additions & 6 deletions src/AppInstallerCLICore/Workflows/ShowFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
12 changes: 12 additions & 0 deletions src/AppInstallerCLICore/Workflows/WorkflowBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Workflows/WorkflowBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down