-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Configure export command #4434
Configure export command #4434
Changes from all commits
85d59dc
98eecca
7e39d57
dc8a7b2
60bc7f4
005683c
a62662d
0598518
bd7b98c
052c1d9
763f186
4486fed
62c92eb
ddc162f
4d6a9ad
9261581
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,64 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "ConfigureExportCommand.h" | ||
#include "Workflows/ConfigurationFlow.h" | ||
#include "ConfigurationCommon.h" | ||
|
||
using namespace AppInstaller::CLI::Workflow; | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
std::vector<Argument> ConfigureExportCommand::GetArguments() const | ||
{ | ||
return { | ||
Argument{ Execution::Args::Type::OutputFile, Resource::String::OutputFileArgumentDescription, true }, | ||
Argument{ Execution::Args::Type::ConfigurationExportPackageId, Resource::String::ConfigureExportPackageId }, | ||
Argument{ Execution::Args::Type::ConfigurationExportModule, Resource::String::ConfigureExportModule }, | ||
Argument{ Execution::Args::Type::ConfigurationExportResource, Resource::String::ConfigureExportResource }, | ||
Argument{ Execution::Args::Type::ConfigurationModulePath, Resource::String::ConfigurationModulePath }, | ||
}; | ||
} | ||
|
||
Resource::LocString ConfigureExportCommand::ShortDescription() const | ||
{ | ||
return { Resource::String::ConfigureExportCommandShortDescription }; | ||
} | ||
|
||
Resource::LocString ConfigureExportCommand::LongDescription() const | ||
{ | ||
return { Resource::String::ConfigureExportCommandLongDescription }; | ||
} | ||
|
||
Utility::LocIndView ConfigureExportCommand::HelpLink() const | ||
{ | ||
return "https://aka.ms/winget-command-configure#export"_liv; | ||
} | ||
|
||
void ConfigureExportCommand::ExecuteInternal(Execution::Context& context) const | ||
{ | ||
context << | ||
VerifyIsFullPackage << | ||
CreateConfigurationProcessor << | ||
CreateOrOpenConfigurationSet << | ||
AddWinGetPackageAndResource << | ||
WriteConfigFile; | ||
} | ||
|
||
void ConfigureExportCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const | ||
{ | ||
Configuration::ValidateCommonArguments(execArgs); | ||
|
||
bool validInputArgs = false; | ||
if (execArgs.Contains(Execution::Args::Type::ConfigurationExportModule, Execution::Args::Type::ConfigurationExportResource) || | ||
execArgs.Contains(Execution::Args::Type::ConfigurationExportPackageId)) | ||
{ | ||
validInputArgs = true; | ||
} | ||
|
||
if (!validInputArgs) | ||
{ | ||
throw CommandException(Resource::String::ConfigureExportArgumentError); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include "Command.h" | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
struct ConfigureExportCommand final : public Command | ||
{ | ||
ConfigureExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ConfigureExport) {} | ||
|
||
std::vector<Argument> GetArguments() const override; | ||
|
||
Resource::LocString ShortDescription() const override; | ||
Resource::LocString LongDescription() const override; | ||
|
||
Utility::LocIndView HelpLink() const override; | ||
|
||
protected: | ||
void ExecuteInternal(Execution::Context& context) const override; | ||
void ValidateArgumentsInternal(Execution::Args& execArgs) const override; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -79,7 +79,6 @@ namespace AppInstaller::CLI::Execution | |||||
Position, | ||||||
|
||||||
// Export Command | ||||||
OutputFile, | ||||||
IncludeVersions, | ||||||
|
||||||
// Import Command | ||||||
|
@@ -126,6 +125,9 @@ namespace AppInstaller::CLI::Execution | |||||
ConfigurationEnable, | ||||||
ConfigurationDisable, | ||||||
ConfigurationModulePath, | ||||||
ConfigurationExportPackageId, | ||||||
ConfigurationExportModule, | ||||||
ConfigurationExportResource, | ||||||
|
||||||
// Common arguments | ||||||
NoVT, // Disable VirtualTerminal outputs | ||||||
|
@@ -138,6 +140,7 @@ namespace AppInstaller::CLI::Execution | |||||
Wait, // Prompts the user to press any key before exiting | ||||||
OpenLogs, // Opens the default logs directory after executing the command | ||||||
Force, // Forces the execution of the workflow with non security related issues | ||||||
OutputFile, | ||||||
|
||||||
DependencySource, // Index source to be queried against for finding dependencies | ||||||
CustomHeader, // Optional Rest source header | ||||||
|
@@ -159,7 +162,11 @@ namespace AppInstaller::CLI::Execution | |||||
Max | ||||||
}; | ||||||
|
||||||
bool Contains(Type arg) const { return (m_parsedArgs.count(arg) != 0); } | ||||||
template<typename... T, std::enable_if_t<(... && std::is_same_v<T, Args::Type>), bool> = true> | ||||||
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. Pretty sure you can just do:
Suggested change
|
||||||
bool Contains(T... arg) const | ||||||
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. You could also use a |
||||||
{ | ||||||
return (... && (m_parsedArgs.count(arg) != 0)); | ||||||
} | ||||||
|
||||||
const std::vector<std::string>* GetArgs(Type arg) const | ||||||
{ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious if there is a design preference here. The subcommands for other areas like pinning are contained within the parent file. For example,
PinRemoveCommand
is contained inPinCommand.h
andSettingsExportCommand
is contained inSettingsCommand.h
. Is there a reason that all the configuration sub commands wouldn't be included inConfigureCommand.h
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2🪙: This isn't large enough to warrant a new file, which is to say that if a subcommand were itself rather complex I think it would be ok to break it out (or if it had its own subcommands, etc.)