-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathInstallCommand.cpp
More file actions
174 lines (160 loc) · 7.03 KB
/
InstallCommand.cpp
File metadata and controls
174 lines (160 loc) · 7.03 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "AppInstallerRuntime.h"
#include "CheckpointManager.h"
#include "InstallCommand.h"
#include "Workflows/CompletionFlow.h"
#include "Workflows/DownloadFlow.h"
#include "Workflows/InstallFlow.h"
#include "Workflows/UpdateFlow.h"
#include "Workflows/MultiQueryFlow.h"
#include "Workflows/ResumeFlow.h"
#include "Workflows/WorkflowBase.h"
#include "Resources.h"
namespace AppInstaller::CLI
{
using namespace AppInstaller::CLI::Execution;
using namespace AppInstaller::CLI::Workflow;
using namespace AppInstaller::Manifest;
using namespace AppInstaller::Utility::literals;
std::vector<Argument> InstallCommand::GetArguments() const
{
return {
Argument::ForType(Args::Type::MultiQuery),
Argument::ForType(Args::Type::Manifest),
Argument::ForType(Args::Type::Id),
Argument::ForType(Args::Type::Name),
Argument::ForType(Args::Type::Moniker),
Argument::ForType(Args::Type::Version),
Argument::ForType(Args::Type::Channel),
Argument::ForType(Args::Type::Source),
Argument{ Args::Type::InstallScope, Resource::String::InstallScopeDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument::ForType(Args::Type::InstallArchitecture),
Argument::ForType(Args::Type::InstallerType),
Argument::ForType(Args::Type::Exact),
Argument::ForType(Args::Type::Interactive),
Argument::ForType(Args::Type::Silent),
Argument::ForType(Args::Type::Locale),
Argument::ForType(Args::Type::Log),
Argument::ForType(Args::Type::CustomSwitches),
Argument::ForType(Args::Type::Override),
Argument::ForType(Args::Type::InstallLocation),
Argument::ForType(Args::Type::HashOverride),
Argument::ForType(Args::Type::AllowReboot),
Argument::ForType(Args::Type::SkipDependencies),
Argument::ForType(Args::Type::IgnoreLocalArchiveMalwareScan),
Argument::ForType(Args::Type::DependencySource),
Argument::ForType(Args::Type::AcceptPackageAgreements),
Argument::ForType(Args::Type::NoUpgrade),
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::Rename),
Argument::ForType(Args::Type::UninstallPrevious),
Argument::ForType(Args::Type::Force),
Argument{ Args::Type::IncludeUnknown, Resource::String::IncludeUnknownArgumentDescription, ArgumentType::Flag, Argument::Visibility::Hidden},
};
}
Resource::LocString InstallCommand::ShortDescription() const
{
return { Resource::String::InstallCommandShortDescription };
}
Resource::LocString InstallCommand::LongDescription() const
{
return { Resource::String::InstallCommandLongDescription };
}
void InstallCommand::Complete(Context& context, Args::Type valueType) const
{
switch (valueType)
{
case Args::Type::MultiQuery:
case Args::Type::Manifest:
case Args::Type::Id:
case Args::Type::Name:
case Args::Type::Moniker:
case Args::Type::Version:
case Args::Type::Channel:
case Args::Type::Source:
context <<
Workflow::CompleteWithSingleSemanticsForValue(valueType);
break;
case Args::Type::InstallArchitecture:
case Args::Type::Locale:
// May well move to CompleteWithSingleSemanticsForValue,
// but for now output nothing.
context <<
Workflow::CompleteWithEmptySet;
break;
case Args::Type::Log:
case Args::Type::InstallLocation:
// Intentionally output nothing to allow pass through to filesystem.
break;
}
}
Utility::LocIndView InstallCommand::HelpLink() const
{
return "https://aka.ms/winget-command-install"_liv;
}
void InstallCommand::ValidateArgumentsInternal(Args& execArgs) const
{
Argument::ValidateCommonArguments(execArgs);
}
void InstallCommand::Resume(Context& context) const
{
// TODO: Load context data from checkpoint for install command.
ExecuteInternal(context);
}
void InstallCommand::ExecuteInternal(Context& context) const
{
context.SetFlags(ContextFlag::ShowSearchResultsOnPartialFailure);
auto overrideArg = context.Args.GetArg(Execution::Args::Type::Override);
if (overrideArg)
{
std::wstring expanded = wil::ExpandEnvironmentStringsW<std::wstring>(overrideArg.value());
context.Args.SetArg(Execution::Args::Type::Override, expanded);
}
context << InitializeInstallerDownloadAuthenticatorsMap;
if (context.Args.Contains(Execution::Args::Type::Manifest))
{
context <<
ReportExecutionStage(ExecutionStage::Discovery) <<
GetManifestFromArg <<
SelectInstaller <<
EnsureApplicableInstaller <<
Checkpoint("PreInstallCheckpoint", {}) << // TODO: Capture context data
InstallSinglePackage;
}
else
{
context <<
ReportExecutionStage(ExecutionStage::Discovery) <<
OpenSource();
if (!context.Args.Contains(Execution::Args::Type::Force))
{
context <<
OpenCompositeSource(DetermineInstalledSource(context), false, Repository::CompositeSearchBehavior::AvailablePackages);
}
if (context.Args.Contains(Execution::Args::Type::MultiQuery))
{
ProcessMultiplePackages::Flags flags = ProcessMultiplePackages::Flags::None;
if (Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies))
{
flags = ProcessMultiplePackages::Flags::IgnoreDependencies;
}
context <<
GetMultiSearchRequests <<
SearchSubContextsForSingle() <<
ReportExecutionStage(ExecutionStage::Execution) <<
ProcessMultiplePackages(Resource::String::PackageRequiresDependencies, APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED, flags);
}
else
{
context <<
Checkpoint("PreInstallCheckpoint", {}) << // TODO: Capture context data
InstallOrUpgradeSinglePackage(OperationType::Install);
}
}
}
}