From 7d6b265e1edca9377721faa38b744d33168654dc Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Wed, 30 Nov 2022 16:01:30 -0800 Subject: [PATCH 01/10] Add empty skeleton for command with gating experimental feature --- .../AppInstallerCLICore.vcxproj | 3 + .../AppInstallerCLICore.vcxproj.filters | 9 + .../Commands/PinCommand.cpp | 166 ++++++++++++++++++ src/AppInstallerCLICore/Commands/PinCommand.h | 91 ++++++++++ .../Commands/RootCommand.cpp | 2 + src/AppInstallerCLICore/Resources.h | 10 ++ src/AppInstallerCLICore/Workflows/PinFlow.h | 8 + .../Shared/Strings/en-us/winget.resw | 40 +++++ .../ExperimentalFeature.cpp | 4 + .../Public/winget/ExperimentalFeature.h | 1 + .../Public/winget/UserSettings.h | 2 + src/AppInstallerCommonCore/UserSettings.cpp | 1 + 12 files changed, 337 insertions(+) create mode 100644 src/AppInstallerCLICore/Commands/PinCommand.cpp create mode 100644 src/AppInstallerCLICore/Commands/PinCommand.h create mode 100644 src/AppInstallerCLICore/Workflows/PinFlow.h diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index a78da26639..effaa5d8b7 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -249,6 +249,7 @@ + @@ -283,6 +284,7 @@ + @@ -299,6 +301,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 5ddf0b00df..53e912fc82 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -188,6 +188,12 @@ Header Files + + Commands + + + Workflows + @@ -343,6 +349,9 @@ Source Files + + Source Files + diff --git a/src/AppInstallerCLICore/Commands/PinCommand.cpp b/src/AppInstallerCLICore/Commands/PinCommand.cpp new file mode 100644 index 0000000000..6c568ab418 --- /dev/null +++ b/src/AppInstallerCLICore/Commands/PinCommand.cpp @@ -0,0 +1,166 @@ +// 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 std::string_view_literals; + + // TODO: Create this link with the docs! + static constexpr std::string_view s_PinCommand_HelpLink = "https://aka.ms/winget-command-pin"sv; + + std::vector> PinCommand::GetCommands() const + { + return InitializeFromMoveOnly>>({ + std::make_unique(FullName()), + std::make_unique(FullName()), + std::make_unique(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 PinAddCommand::GetArguments() const + { + // TODO + } + + Resource::LocString PinAddCommand::ShortDescription() const + { + return { Resource::String::PinAddCommandShortDescription }; + } + + Resource::LocString PinAddCommand::LongDescription() const + { + return { Resource::String::PinAddCommandLongDescription }; + } + + void PinAddCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + { + // TODO + } + + std::string PinAddCommand::HelpLink() const + { + return std::string{ s_PinCommand_HelpLink }; + } + + void PinAddCommand::ExecuteInternal(Execution::Context& context) const + { + // TODO + } + + std::vector PinRemoveCommand::GetArguments() const + { + // TODO + } + + Resource::LocString PinRemoveCommand::ShortDescription() const + { + return { Resource::String::PinRemoveCommandShortDescription }; + } + + Resource::LocString PinRemoveCommand::LongDescription() const + { + return { Resource::String::PinRemoveCommandLongDescription }; + } + + void PinRemoveCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + { + // TODO + } + + std::string PinRemoveCommand::HelpLink() const + { + return std::string{ s_PinCommand_HelpLink }; + } + + void PinRemoveCommand::ExecuteInternal(Execution::Context& context) const + { + // TODO + } + + std::vector PinListCommand::GetArguments() const + { + // TODO + } + + Resource::LocString PinListCommand::ShortDescription() const + { + return { Resource::String::PinListCommandShortDescription }; + } + + Resource::LocString PinListCommand::LongDescription() const + { + return { Resource::String::PinListCommandLongDescription }; + } + + void PinListCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + { + // TODO + } + + std::string PinListCommand::HelpLink() const + { + return std::string{ s_PinCommand_HelpLink }; + } + + void PinListCommand::ExecuteInternal(Execution::Context& context) const + { + // TODO + } + + std::vector PinResetCommand::GetArguments() const + { + // TODO + } + + Resource::LocString PinResetCommand::ShortDescription() const + { + return { Resource::String::PinResetCommandShortDescription }; + } + + Resource::LocString PinResetCommand::LongDescription() const + { + return { Resource::String::PinResetCommandLongDescription }; + } + + void PinResetCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + { + // TODO + } + + std::string PinResetCommand::HelpLink() const + { + return std::string{ s_PinCommand_HelpLink }; + } + + void PinResetCommand::ExecuteInternal(Execution::Context& context) const + { + // TODO + } +} diff --git a/src/AppInstallerCLICore/Commands/PinCommand.h b/src/AppInstallerCLICore/Commands/PinCommand.h new file mode 100644 index 0000000000..b1d304d5c0 --- /dev/null +++ b/src/AppInstallerCLICore/Commands/PinCommand.h @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "Command.h" +#include + +namespace AppInstaller::CLI +{ + struct PinCommand final : public Command + { + PinCommand(std::string_view parent) : Command("pin", {} /* aliases */, parent, Settings::ExperimentalFeature::Feature::Pinning) {} + + std::vector> GetCommands() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + std::string HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; + + struct PinAddCommand final : public Command + { + PinAddCommand(std::string_view parent) : Command("add", parent) {} + + std::vector GetArguments() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; + + std::string HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; + + struct PinRemoveCommand final : public Command + { + PinRemoveCommand(std::string_view parent) : Command("remove", parent) {} + + std::vector GetArguments() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; + + std::string HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; + + struct PinListCommand final : public Command + { + PinListCommand(std::string_view parent) : Command("list", parent) {} + + std::vector GetArguments() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; + + std::string HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; + + struct PinResetCommand final : public Command + { + PinResetCommand(std::string_view parent) : Command("reset", parent) {} + + std::vector GetArguments() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; + + std::string HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; +} diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp index f07358655e..ebf081e4df 100644 --- a/src/AppInstallerCLICore/Commands/RootCommand.cpp +++ b/src/AppInstallerCLICore/Commands/RootCommand.cpp @@ -18,6 +18,7 @@ #include "CompleteCommand.h" #include "ExportCommand.h" #include "ImportCommand.h" +#include "PinCommand.h" #include "Resources.h" #include "TableOutput.h" @@ -127,6 +128,7 @@ namespace AppInstaller::CLI std::make_unique(FullName()), std::make_unique(FullName()), std::make_unique(FullName()), + std::make_unique(FullName()), }); } diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 9ac6f3d06d..871ffa0bed 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -237,6 +237,16 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(PackageAlreadyInstalled); WINGET_DEFINE_RESOURCE_STRINGID(PackageDependencies); WINGET_DEFINE_RESOURCE_STRINGID(PendingWorkError); + WINGET_DEFINE_RESOURCE_STRINGID(PinAddCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinAddCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinListCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinListCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinRemoveCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinRemoveCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinResetCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(PinResetCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(PoliciesDisabled); WINGET_DEFINE_RESOURCE_STRINGID(PoliciesEnabled); WINGET_DEFINE_RESOURCE_STRINGID(PoliciesPolicy); diff --git a/src/AppInstallerCLICore/Workflows/PinFlow.h b/src/AppInstallerCLICore/Workflows/PinFlow.h new file mode 100644 index 0000000000..504ed5782e --- /dev/null +++ b/src/AppInstallerCLICore/Workflows/PinFlow.h @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "ExecutionContext.h" + +namespace AppInstaller::CLI::Workflow +{ +} diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 947caa549a..3a3f10b24c 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1485,4 +1485,44 @@ Please specify one of them using the --source option to proceed. Cannot disable %1. This setting is controlled by policy. For more information contact your system administrator. {Locked="%1"} The value will be replaced with the feature name + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + + + + TODO + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 49067ae966..22bcec667a 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -46,6 +46,8 @@ namespace AppInstaller::Settings return userSettings.Get(); case ExperimentalFeature::Feature::OpenLogsArgument: return userSettings.Get(); + case ExperimentalFeature::Feature::Pinning: + return userSettings.Get(); default: THROW_HR(E_UNEXPECTED); } @@ -81,6 +83,8 @@ namespace AppInstaller::Settings return ExperimentalFeature{ "Zip Installation", "zipInstall", "https://aka.ms/winget-settings", Feature::ZipInstall }; case Feature::OpenLogsArgument: return ExperimentalFeature{ "Open Logs Argument", "openLogsArgument", "https://aka.ms/winget-settings", Feature::OpenLogsArgument }; + case Feature::Pinning: + return ExperimentalFeature{ "Package Pinning", "pinning", "https://aka.ms/winget-settings", Feature::Pinning}; default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index 76ac6e7523..acbb2d5fbb 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -25,6 +25,7 @@ namespace AppInstaller::Settings DirectMSI = 0x2, ZipInstall = 0x4, OpenLogsArgument = 0x8, + Pinning = 0xA, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index b6e4a9b2cf..ec14844426 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -79,6 +79,7 @@ namespace AppInstaller::Settings EFDirectMSI, EFZipInstall, EFOpenLogsArgument, + EFPinning, // Telemetry TelemetryDisable, // Install behavior @@ -148,6 +149,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFDirectMSI, bool, bool, false, ".experimentalFeatures.directMSI"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFZipInstall, bool, bool, false, ".experimentalFeatures.zipInstall"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFOpenLogsArgument, bool, bool, false, ".experimentalFeatures.openLogsArgument"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFPinning, bool, bool, false, ".experimentalFeatures.pinning"sv); // Telemetry SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); // Install behavior diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index ac842a19e6..c97d086868 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -249,6 +249,7 @@ namespace AppInstaller::Settings WINGET_VALIDATE_PASS_THROUGH(EFDirectMSI) WINGET_VALIDATE_PASS_THROUGH(EFZipInstall) WINGET_VALIDATE_PASS_THROUGH(EFOpenLogsArgument) + WINGET_VALIDATE_PASS_THROUGH(EFPinning) WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable) WINGET_VALIDATE_PASS_THROUGH(InteractivityDisable) WINGET_VALIDATE_PASS_THROUGH(EnableSelfInitiatedMinidump) From fa20950033a81ea37eff05ebe9254c40c51ac4ec Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 1 Dec 2022 12:46:16 -0800 Subject: [PATCH 02/10] Add command arguments --- .../Commands/PinCommand.cpp | 108 +++++++++++++++--- src/AppInstallerCLICore/Commands/PinCommand.h | 3 +- src/AppInstallerCLICore/ExecutionArgs.h | 4 + src/AppInstallerCLICore/Resources.h | 3 + .../Shared/Strings/en-us/winget.resw | 12 ++ 5 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/PinCommand.cpp b/src/AppInstallerCLICore/Commands/PinCommand.cpp index 6c568ab418..d5943528c7 100644 --- a/src/AppInstallerCLICore/Commands/PinCommand.cpp +++ b/src/AppInstallerCLICore/Commands/PinCommand.cpp @@ -10,6 +10,7 @@ namespace AppInstaller::CLI { using namespace AppInstaller::CLI::Execution; + using namespace AppInstaller::Utility::literals; using namespace std::string_view_literals; // TODO: Create this link with the docs! @@ -46,7 +47,21 @@ namespace AppInstaller::CLI std::vector PinAddCommand::GetArguments() const { - // TODO + 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), + Argument{ "blocking"_liv, Argument::NoAlias, Args::Type::BlockingPin, Resource::String::PinAddBlockingArgumentDescription, ArgumentType::Flag }, + }; } Resource::LocString PinAddCommand::ShortDescription() const @@ -59,9 +74,19 @@ namespace AppInstaller::CLI return { Resource::String::PinAddCommandLongDescription }; } - void PinAddCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + void PinAddCommand::Complete(Execution::Context& context, Args::Type valueType) const { - // TODO + 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 @@ -69,14 +94,36 @@ namespace AppInstaller::CLI 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 PinRemoveCommand::GetArguments() const { - // TODO + 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), + Argument::ForType(Args::Type::Force), + }; } Resource::LocString PinRemoveCommand::ShortDescription() const @@ -89,9 +136,19 @@ namespace AppInstaller::CLI return { Resource::String::PinRemoveCommandLongDescription }; } - void PinRemoveCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + void PinRemoveCommand::Complete(Execution::Context& context, Args::Type valueType) const { - // TODO + 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 @@ -102,11 +159,23 @@ namespace AppInstaller::CLI void PinRemoveCommand::ExecuteInternal(Execution::Context& context) const { // TODO + Command::ExecuteInternal(context); } std::vector PinListCommand::GetArguments() const { - // TODO + 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 @@ -119,9 +188,19 @@ namespace AppInstaller::CLI return { Resource::String::PinListCommandLongDescription }; } - void PinListCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const + void PinListCommand::Complete(Execution::Context& context, Args::Type valueType) const { - // TODO + 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 @@ -132,11 +211,14 @@ namespace AppInstaller::CLI void PinListCommand::ExecuteInternal(Execution::Context& context) const { // TODO + Command::ExecuteInternal(context); } std::vector PinResetCommand::GetArguments() const { - // TODO + return { + Argument::ForType(Args::Type::Force), + }; } Resource::LocString PinResetCommand::ShortDescription() const @@ -149,11 +231,6 @@ namespace AppInstaller::CLI return { Resource::String::PinResetCommandLongDescription }; } - void PinResetCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const - { - // TODO - } - std::string PinResetCommand::HelpLink() const { return std::string{ s_PinCommand_HelpLink }; @@ -162,5 +239,6 @@ namespace AppInstaller::CLI void PinResetCommand::ExecuteInternal(Execution::Context& context) const { // TODO + Command::ExecuteInternal(context); } } diff --git a/src/AppInstallerCLICore/Commands/PinCommand.h b/src/AppInstallerCLICore/Commands/PinCommand.h index b1d304d5c0..8740971b9d 100644 --- a/src/AppInstallerCLICore/Commands/PinCommand.h +++ b/src/AppInstallerCLICore/Commands/PinCommand.h @@ -35,6 +35,7 @@ namespace AppInstaller::CLI std::string HelpLink() const override; protected: + void ValidateArgumentsInternal(Execution::Args& execArgs) const override; void ExecuteInternal(Execution::Context& context) const override; }; @@ -81,8 +82,6 @@ namespace AppInstaller::CLI Resource::LocString ShortDescription() const override; Resource::LocString LongDescription() const override; - void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; - std::string HelpLink() const override; protected: diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h index fd3d196b72..d0df99a98f 100644 --- a/src/AppInstallerCLICore/ExecutionArgs.h +++ b/src/AppInstallerCLICore/ExecutionArgs.h @@ -87,6 +87,10 @@ namespace AppInstaller::CLI::Execution // Show command ListVersions, // Used in Show command to list all available versions of an app + // Pin command + GatedVersion, // Differs from Version in that this supports wildcards + BlockingPin, + // Common arguments NoVT, // Disable VirtualTerminal outputs RetroStyle, // Makes progress display as retro diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 871ffa0bed..1122c02259 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -36,6 +36,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(AvailableOptions); WINGET_DEFINE_RESOURCE_STRINGID(AvailableSubcommands); WINGET_DEFINE_RESOURCE_STRINGID(AvailableUpgrades); + WINGET_DEFINE_RESOURCE_STRINGID(BothGatedVersionAndBlockingFlagProvided); WINGET_DEFINE_RESOURCE_STRINGID(BothManifestAndSearchQueryProvided); WINGET_DEFINE_RESOURCE_STRINGID(BothPurgeAndPreserveFlagsProvided); WINGET_DEFINE_RESOURCE_STRINGID(Cancelled); @@ -96,6 +97,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory); WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); + WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound); WINGET_DEFINE_RESOURCE_STRINGID(HashCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(HashCommandShortDescription); @@ -237,6 +239,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(PackageAlreadyInstalled); WINGET_DEFINE_RESOURCE_STRINGID(PackageDependencies); WINGET_DEFINE_RESOURCE_STRINGID(PendingWorkError); + WINGET_DEFINE_RESOURCE_STRINGID(PinAddBlockingArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(PinAddCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(PinAddCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(PinCommandLongDescription); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 3a3f10b24c..831f2aae7b 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1525,4 +1525,16 @@ Please specify one of them using the --source option to proceed. TODO + + + TODO + + + + TODO + + + + TODO + \ No newline at end of file From cfc29a8fc3b630023a6fab33d7a93bd3b8dc48e6 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 1 Dec 2022 16:08:38 -0800 Subject: [PATCH 03/10] Add resource strings --- .../Shared/Strings/en-us/winget.resw | 43 ++++++++----------- .../Public/winget/ExperimentalFeature.h | 2 +- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 831f2aae7b..5491ff4bf3 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1486,55 +1486,46 @@ Please specify one of them using the --source option to proceed. {Locked="%1"} The value will be replaced with the feature name - - TODO + Add a new pin. A pin can limit the Windows Package Manager from updating a package to specific ranges of versions, or it can prevent it from updating the package altogether. A pinned package may still update on its own and be updated from outside the Windows Package Manager. By default, a pinned package can be updated by mentioning it explicitly in the 'upgrade' command or by adding the '--include-pinned' flag to 'winget upgrade --all'. + {Locked{"'upgrade'"} Locked{"--include-pinned"} Locked{"winget upgrade --all"} - - TODO + Add a new pin - - TODO + Manage package pins with the sub-commands. A pin can limit the Windows Package Manager from updating a package to specific ranges of versions, or it can prevent it from updating the package altogether. A pinned package may still update on its own and be updated from outside the Windows Package Manager. - - TODO + + Manage package pins - - TODO + List all current pins, or full details of a specific pin. - - TODO + + List current pins - - TODO + Remove a specific package pin. - - TODO + Remove a package pin - - TODO + Reset all existing pins. - - TODO + Reset pins - - TODO + Both version and '--blocking' arguments provided + {Locked="--blocking"} - - TODO + Version to which to pin the package. The wildcard '*' can be used as the last version part - - TODO + Block from updating until the pin is removed, preventing override arguments \ No newline at end of file diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index acbb2d5fbb..ac707a52d5 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -25,7 +25,7 @@ namespace AppInstaller::Settings DirectMSI = 0x2, ZipInstall = 0x4, OpenLogsArgument = 0x8, - Pinning = 0xA, + Pinning = 0x1, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command From 4b644393a58763d8b1a9d7af58d708c413c610ee Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 1 Dec 2022 16:10:02 -0800 Subject: [PATCH 04/10] Fix hex code --- src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index ac707a52d5..f34b24d2c3 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -25,7 +25,7 @@ namespace AppInstaller::Settings DirectMSI = 0x2, ZipInstall = 0x4, OpenLogsArgument = 0x8, - Pinning = 0x1, + Pinning = 0x10, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command From f17d1352d02837c1de99ad8ba94f6972e7e87336 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 1 Dec 2022 16:57:13 -0800 Subject: [PATCH 05/10] Fix value-comment switch --- src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 5491ff4bf3..4b81fdd476 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1503,8 +1503,7 @@ Please specify one of them using the --source option to proceed. List all current pins, or full details of a specific pin. - - List current pins + List current pins Remove a specific package pin. From c60bd62a381d79300b6da227c78639858d236469 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 1 Dec 2022 17:02:43 -0800 Subject: [PATCH 06/10] Update settings.md to include pinning --- doc/Settings.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/Settings.md b/doc/Settings.md index b2a7cd98f9..275c35b632 100644 --- a/doc/Settings.md +++ b/doc/Settings.md @@ -253,7 +253,8 @@ You can enable the feature as shown below. "openLogsArgument": true }, ``` -### Dependencies + +### dependencies Experimental feature with the aim of managing dependencies, as of now it only shows package dependency information. You can enable the feature as shown below. @@ -262,3 +263,14 @@ Experimental feature with the aim of managing dependencies, as of now it only sh "dependencies": true }, ``` + +### pinning + +This feature enables the ability to pin packages to a specific version to prevent the Windows Package Manager from updating them. +You can enable the feature as shown below. + +```json + "experimentalFeatures": { + "openLogsArgument": true + }, +``` \ No newline at end of file From 24ba03892eb6e3da4517ec5d18bf11138e2133d8 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Fri, 2 Dec 2022 14:20:46 -0800 Subject: [PATCH 07/10] Undo changes moved to new PR --- src/AppInstallerCLICore/Commands/SourceCommand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCLICore/Commands/SourceCommand.h b/src/AppInstallerCLICore/Commands/SourceCommand.h index 9c54e6b164..c0b1a581db 100644 --- a/src/AppInstallerCLICore/Commands/SourceCommand.h +++ b/src/AppInstallerCLICore/Commands/SourceCommand.h @@ -37,7 +37,7 @@ namespace AppInstaller::CLI struct SourceListCommand final : public Command { - SourceListCommand(std::string_view parent) : Command("list", { "ls" }, parent) {} + SourceListCommand(std::string_view parent) : Command("list", parent) {} std::vector GetArguments() const override; From cbb64b962d5d08f6207d4c508a1a9a17a0b89665 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Fri, 2 Dec 2022 14:26:00 -0800 Subject: [PATCH 08/10] PR comments --- doc/Settings.md | 2 +- src/AppInstallerCLICore/Commands/PinCommand.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Settings.md b/doc/Settings.md index 275c35b632..d5d1b923af 100644 --- a/doc/Settings.md +++ b/doc/Settings.md @@ -271,6 +271,6 @@ You can enable the feature as shown below. ```json "experimentalFeatures": { - "openLogsArgument": true + "pinning": true }, ``` \ No newline at end of file diff --git a/src/AppInstallerCLICore/Commands/PinCommand.cpp b/src/AppInstallerCLICore/Commands/PinCommand.cpp index d5943528c7..70237e966f 100644 --- a/src/AppInstallerCLICore/Commands/PinCommand.cpp +++ b/src/AppInstallerCLICore/Commands/PinCommand.cpp @@ -22,6 +22,7 @@ namespace AppInstaller::CLI std::make_unique(FullName()), std::make_unique(FullName()), std::make_unique(FullName()), + std::make_unique(FullName()), }); } From 9b9e4e32e162c76d1d8e9de5ce82000d9c05497c Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Mon, 5 Dec 2022 14:33:59 -0800 Subject: [PATCH 09/10] Remove unneeded comment --- src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 4b81fdd476..73044e944f 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1496,7 +1496,6 @@ Please specify one of them using the --source option to proceed. Manage package pins with the sub-commands. A pin can limit the Windows Package Manager from updating a package to specific ranges of versions, or it can prevent it from updating the package altogether. A pinned package may still update on its own and be updated from outside the Windows Package Manager. - Manage package pins From 2157ee6adb97be22ca399b5ecf9fa49a0df3f1d0 Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 8 Dec 2022 10:27:10 -0800 Subject: [PATCH 10/10] PR comments --- doc/Settings.md | 2 +- src/AppInstallerCLICore/Commands/PinCommand.cpp | 2 -- src/AppInstallerCLICore/Commands/SourceCommand.h | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/Settings.md b/doc/Settings.md index d5d1b923af..f0d09d3b2d 100644 --- a/doc/Settings.md +++ b/doc/Settings.md @@ -266,7 +266,7 @@ Experimental feature with the aim of managing dependencies, as of now it only sh ### pinning -This feature enables the ability to pin packages to a specific version to prevent the Windows Package Manager from updating them. +This feature enables the ability to pin packages to prevent the Windows Package Manager from updating them. You can enable the feature as shown below. ```json diff --git a/src/AppInstallerCLICore/Commands/PinCommand.cpp b/src/AppInstallerCLICore/Commands/PinCommand.cpp index 70237e966f..5cdedb26b0 100644 --- a/src/AppInstallerCLICore/Commands/PinCommand.cpp +++ b/src/AppInstallerCLICore/Commands/PinCommand.cpp @@ -13,7 +13,6 @@ namespace AppInstaller::CLI using namespace AppInstaller::Utility::literals; using namespace std::string_view_literals; - // TODO: Create this link with the docs! static constexpr std::string_view s_PinCommand_HelpLink = "https://aka.ms/winget-command-pin"sv; std::vector> PinCommand::GetCommands() const @@ -123,7 +122,6 @@ namespace AppInstaller::CLI Argument::ForType(Args::Type::Exact), Argument::ForType(Args::Type::CustomHeader), Argument::ForType(Args::Type::AcceptSourceAgreements), - Argument::ForType(Args::Type::Force), }; } diff --git a/src/AppInstallerCLICore/Commands/SourceCommand.h b/src/AppInstallerCLICore/Commands/SourceCommand.h index c0b1a581db..9c54e6b164 100644 --- a/src/AppInstallerCLICore/Commands/SourceCommand.h +++ b/src/AppInstallerCLICore/Commands/SourceCommand.h @@ -37,7 +37,7 @@ namespace AppInstaller::CLI struct SourceListCommand final : public Command { - SourceListCommand(std::string_view parent) : Command("list", parent) {} + SourceListCommand(std::string_view parent) : Command("list", { "ls" }, parent) {} std::vector GetArguments() const override;