forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfigureExportCommand.cpp
More file actions
74 lines (65 loc) · 3.53 KB
/
ConfigureExportCommand.cpp
File metadata and controls
74 lines (65 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "ConfigureExportCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.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 },
Argument::ForType(Execution::Args::Type::ConfigurationProcessorPath),
Argument{ Execution::Args::Type::Source, Resource::String::ExportSourceArgumentDescription, ArgumentType::Standard },
Argument{ Execution::Args::Type::IncludeVersions, Resource::String::ExportIncludeVersionsArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::ConfigurationExportAll, Resource::String::ConfigureExportAll, ArgumentType::Flag },
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
};
}
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 <<
CreateConfigurationProcessorWithoutFactory <<
CreateOrOpenConfigurationSet{ "0.3", context.Args.Contains(Execution::Args::Type::ConfigurationExportAll) } <<
CreateConfigurationProcessor <<
PopulateConfigurationSetForExport <<
WriteConfigFile;
}
void ConfigureExportCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
Configuration::ValidateCommonArguments(execArgs);
if (!execArgs.Contains(Execution::Args::Type::ConfigurationExportModule, Execution::Args::Type::ConfigurationExportResource) &&
!execArgs.Contains(Execution::Args::Type::ConfigurationExportPackageId) &&
!execArgs.Contains(Execution::Args::Type::ConfigurationExportAll))
{
throw CommandException(Resource::String::ConfigureExportArgumentRequiredError);
}
if (execArgs.Contains(Execution::Args::Type::ConfigurationExportAll) &&
(execArgs.Contains(Execution::Args::Type::ConfigurationExportPackageId) ||
execArgs.Contains(Execution::Args::Type::ConfigurationExportModule) ||
execArgs.Contains(Execution::Args::Type::ConfigurationExportResource)))
{
throw CommandException(Resource::String::ConfigureExportArgumentConflictWithAllError);
}
}
}