-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add empty pin command
#2733
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
Add empty pin command
#2733
Changes from all commits
7d6b265
fa20950
cfc29a8
4b64439
f17d135
c60bd62
24ba038
cbb64b9
9b9e4e3
2157ee6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| #include "pch.h" | ||
| #include "PinCommand.h" | ||
| #include "Workflows/CompletionFlow.h" | ||
| #include "Workflows/PinFlow.h" | ||
| #include "Workflows/WorkflowBase.h" | ||
| #include "Resources.h" | ||
|
|
||
| namespace AppInstaller::CLI | ||
| { | ||
| using namespace AppInstaller::CLI::Execution; | ||
| using namespace AppInstaller::Utility::literals; | ||
| using namespace std::string_view_literals; | ||
|
|
||
| static constexpr std::string_view s_PinCommand_HelpLink = "https://aka.ms/winget-command-pin"sv; | ||
|
|
||
| std::vector<std::unique_ptr<Command>> PinCommand::GetCommands() const | ||
| { | ||
| return InitializeFromMoveOnly<std::vector<std::unique_ptr<Command>>>({ | ||
| std::make_unique<PinAddCommand>(FullName()), | ||
| std::make_unique<PinRemoveCommand>(FullName()), | ||
| std::make_unique<PinListCommand>(FullName()), | ||
|
florelis marked this conversation as resolved.
|
||
| std::make_unique<PinResetCommand>(FullName()), | ||
| }); | ||
| } | ||
|
|
||
| Resource::LocString PinCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::PinCommandShortDescription }; | ||
| } | ||
|
|
||
| Resource::LocString PinCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::PinCommandLongDescription }; | ||
| } | ||
|
|
||
| std::string PinCommand::HelpLink() const | ||
| { | ||
| return std::string{ s_PinCommand_HelpLink }; | ||
| } | ||
|
|
||
| void PinCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| OutputHelp(context.Reporter); | ||
| } | ||
|
|
||
| std::vector<Argument> PinAddCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::ForType(Args::Type::Query), | ||
| Argument::ForType(Args::Type::Id), | ||
| Argument::ForType(Args::Type::Name), | ||
| Argument::ForType(Args::Type::Moniker), | ||
| Argument::ForType(Args::Type::Tag), | ||
| Argument::ForType(Args::Type::Command), | ||
| Argument::ForType(Args::Type::Exact), | ||
| Argument{ "version"_liv, 'v', Args::Type::GatedVersion, Resource::String::GatedVersionArgumentDescription, ArgumentType::Standard }, | ||
| Argument::ForType(Args::Type::Source), | ||
| Argument::ForType(Args::Type::CustomHeader), | ||
| Argument::ForType(Args::Type::AcceptSourceAgreements), | ||
| Argument::ForType(Args::Type::Force), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious what is the scenario for --force in pin add?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scenario I was thinking of is overwriting the pin. Like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I guess I thought about it some time ago and now my memory does not serve me well.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even more curious - should |
||
| Argument{ "blocking"_liv, Argument::NoAlias, Args::Type::BlockingPin, Resource::String::PinAddBlockingArgumentDescription, ArgumentType::Flag }, | ||
| }; | ||
| } | ||
|
|
||
| Resource::LocString PinAddCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::PinAddCommandShortDescription }; | ||
| } | ||
|
|
||
| Resource::LocString PinAddCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::PinAddCommandLongDescription }; | ||
| } | ||
|
|
||
| void PinAddCommand::Complete(Execution::Context& context, Args::Type valueType) const | ||
| { | ||
| switch (valueType) | ||
| { | ||
| case Args::Type::Query: | ||
| case Args::Type::Id: | ||
| case Args::Type::Name: | ||
| case Args::Type::Moniker: | ||
| case Args::Type::Source: | ||
| context << | ||
| Workflow::CompleteWithSingleSemanticsForValue(valueType); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::string PinAddCommand::HelpLink() const | ||
| { | ||
| return std::string{ s_PinCommand_HelpLink }; | ||
| } | ||
|
|
||
| void PinAddCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const | ||
| { | ||
| if (execArgs.Contains(Execution::Args::Type::GatedVersion) && execArgs.Contains(Execution::Args::Type::BlockingPin)) | ||
| { | ||
| throw CommandException(Resource::String::BothGatedVersionAndBlockingFlagProvided); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| void PinAddCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| // TODO | ||
| Command::ExecuteInternal(context); | ||
| } | ||
|
|
||
| std::vector<Argument> PinRemoveCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::ForType(Args::Type::Query), | ||
| Argument::ForType(Args::Type::Id), | ||
| Argument::ForType(Args::Type::Name), | ||
| Argument::ForType(Args::Type::Moniker), | ||
| Argument::ForType(Args::Type::Source), | ||
| Argument::ForType(Args::Type::Tag), | ||
| Argument::ForType(Args::Type::Command), | ||
| Argument::ForType(Args::Type::Exact), | ||
| Argument::ForType(Args::Type::CustomHeader), | ||
| Argument::ForType(Args::Type::AcceptSourceAgreements), | ||
| }; | ||
| } | ||
|
|
||
| Resource::LocString PinRemoveCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::PinRemoveCommandShortDescription }; | ||
| } | ||
|
|
||
| Resource::LocString PinRemoveCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::PinRemoveCommandLongDescription }; | ||
| } | ||
|
|
||
| void PinRemoveCommand::Complete(Execution::Context& context, Args::Type valueType) const | ||
| { | ||
| switch (valueType) | ||
| { | ||
| case Args::Type::Query: | ||
| case Args::Type::Id: | ||
| case Args::Type::Name: | ||
| case Args::Type::Moniker: | ||
| case Args::Type::Source: | ||
| context << | ||
| Workflow::CompleteWithSingleSemanticsForValue(valueType); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::string PinRemoveCommand::HelpLink() const | ||
| { | ||
| return std::string{ s_PinCommand_HelpLink }; | ||
| } | ||
|
|
||
| void PinRemoveCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| // TODO | ||
| Command::ExecuteInternal(context); | ||
| } | ||
|
|
||
| std::vector<Argument> PinListCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::ForType(Args::Type::Query), | ||
| Argument::ForType(Args::Type::Id), | ||
| Argument::ForType(Args::Type::Name), | ||
| Argument::ForType(Args::Type::Moniker), | ||
| Argument::ForType(Args::Type::Source), | ||
| Argument::ForType(Args::Type::Tag), | ||
| Argument::ForType(Args::Type::Command), | ||
| Argument::ForType(Args::Type::Exact), | ||
| Argument::ForType(Args::Type::CustomHeader), | ||
| Argument::ForType(Args::Type::AcceptSourceAgreements), | ||
| }; | ||
| } | ||
|
|
||
| Resource::LocString PinListCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::PinListCommandShortDescription }; | ||
| } | ||
|
|
||
| Resource::LocString PinListCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::PinListCommandLongDescription }; | ||
| } | ||
|
|
||
| void PinListCommand::Complete(Execution::Context& context, Args::Type valueType) const | ||
| { | ||
| switch (valueType) | ||
| { | ||
| case Args::Type::Query: | ||
| case Args::Type::Id: | ||
| case Args::Type::Name: | ||
| case Args::Type::Moniker: | ||
| case Args::Type::Source: | ||
| context << | ||
| Workflow::CompleteWithSingleSemanticsForValue(valueType); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::string PinListCommand::HelpLink() const | ||
| { | ||
| return std::string{ s_PinCommand_HelpLink }; | ||
| } | ||
|
|
||
| void PinListCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| // TODO | ||
| Command::ExecuteInternal(context); | ||
| } | ||
|
|
||
| std::vector<Argument> PinResetCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::ForType(Args::Type::Force), | ||
| }; | ||
| } | ||
|
|
||
| Resource::LocString PinResetCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::PinResetCommandShortDescription }; | ||
| } | ||
|
|
||
| Resource::LocString PinResetCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::PinResetCommandLongDescription }; | ||
| } | ||
|
|
||
| std::string PinResetCommand::HelpLink() const | ||
| { | ||
| return std::string{ s_PinCommand_HelpLink }; | ||
| } | ||
|
|
||
| void PinResetCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| // TODO | ||
| Command::ExecuteInternal(context); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.