ConfigureListCommand.cpp (3546B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "ConfigureListCommand.h" 5 #include "Workflows/ConfigurationFlow.h" 6 #include "Workflows/MSStoreInstallerHandler.h" 7 #include "ConfigurationCommon.h" 8 9 using namespace AppInstaller::CLI::Workflow; 10 11 namespace AppInstaller::CLI 12 { 13 std::vector<Argument> ConfigureListCommand::GetArguments() const 14 { 15 return { 16 Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard }, 17 Argument{ Execution::Args::Type::OutputFile, Resource::String::OutputFileArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help }, 18 Argument{ Execution::Args::Type::ConfigurationHistoryRemove, Resource::String::ConfigurationHistoryRemoveArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help }, 19 Argument{ Execution::Args::Type::ConfigurationStatusWatch, Resource::String::ConfigurationStatusWatchArgumentDescription, ArgumentType::Flag, Argument::Visibility::Hidden }, 20 }; 21 } 22 23 Resource::LocString ConfigureListCommand::ShortDescription() const 24 { 25 return { Resource::String::ConfigureListCommandShortDescription }; 26 } 27 28 Resource::LocString ConfigureListCommand::LongDescription() const 29 { 30 return { Resource::String::ConfigureListCommandLongDescription }; 31 } 32 33 Utility::LocIndView ConfigureListCommand::HelpLink() const 34 { 35 return "https://aka.ms/winget-command-configure#list"_liv; 36 } 37 38 void ConfigureListCommand::ExecuteInternal(Execution::Context& context) const 39 { 40 context << 41 VerifyIsFullPackage << 42 CreateConfigurationProcessorWithoutFactory << 43 GetConfigurationSetHistory; 44 45 if (context.Args.Contains(Execution::Args::Type::ConfigurationHistoryItem)) 46 { 47 context << SelectSetFromHistory; 48 49 if (context.Args.Contains(Execution::Args::Type::OutputFile)) 50 { 51 context << SerializeConfigurationSetHistory; 52 } 53 54 if (context.Args.Contains(Execution::Args::Type::ConfigurationHistoryRemove)) 55 { 56 context << RemoveConfigurationSetHistory; 57 } 58 else 59 { 60 context << ShowSingleConfigurationSetHistory; 61 } 62 } 63 else if (context.Args.Contains(Execution::Args::Type::ConfigurationStatusWatch)) 64 { 65 context << MonitorConfigurationStatus; 66 } 67 else 68 { 69 context << ShowConfigurationSetHistory; 70 } 71 } 72 73 void ConfigureListCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const 74 { 75 if ((execArgs.Contains(Execution::Args::Type::ConfigurationHistoryRemove) || 76 execArgs.Contains(Execution::Args::Type::OutputFile)) && 77 !execArgs.Contains(Execution::Args::Type::ConfigurationHistoryItem)) 78 { 79 throw CommandException(Resource::String::RequiredArgError(ArgumentCommon::ForType(Execution::Args::Type::ConfigurationHistoryItem).Name)); 80 } 81 } 82 83 void ConfigureListCommand::Complete(Execution::Context& context, Execution::Args::Type argType) const 84 { 85 if (argType == Execution::Args::Type::ConfigurationHistoryItem) 86 { 87 context << CompleteConfigurationHistoryItem; 88 } 89 } 90 }