-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathListCommand.cpp
More file actions
100 lines (90 loc) · 4.63 KB
/
ListCommand.cpp
File metadata and controls
100 lines (90 loc) · 4.63 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "ListCommand.h"
#include "Workflows/CompletionFlow.h"
#include "Workflows/WorkflowBase.h"
#include "Resources.h"
namespace AppInstaller::CLI
{
using namespace AppInstaller::CLI::Workflow;
using namespace std::string_view_literals;
std::vector<Argument> ListCommand::GetArguments() const
{
return {
Argument::ForType(Execution::Args::Type::Query),
Argument::ForType(Execution::Args::Type::Id),
Argument::ForType(Execution::Args::Type::Name),
Argument::ForType(Execution::Args::Type::Moniker),
Argument::ForType(Execution::Args::Type::Source),
Argument::ForType(Execution::Args::Type::Tag),
Argument::ForType(Execution::Args::Type::Command),
Argument::ForType(Execution::Args::Type::Count),
Argument::ForType(Execution::Args::Type::Exact),
Argument{ Execution::Args::Type::InstallScope, Resource::String::InstalledScopeArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument::ForType(Execution::Args::Type::CustomHeader),
Argument::ForType(Execution::Args::Type::AuthenticationMode),
Argument::ForType(Execution::Args::Type::AuthenticationAccount),
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
Argument{ Execution::Args::Type::Upgrade, Resource::String::UpgradeArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::IncludeUnknown, Resource::String::IncludeUnknownInListArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::IncludePinned, Resource::String::IncludePinnedInListArgumentDescription, ArgumentType::Flag},
Argument::ForType(Execution::Args::Type::ListDetails),
Argument{ Execution::Args::Type::Sort, Resource::String::SortArgumentDescription, ArgumentType::Standard }.SetCountLimit(6),
Argument{ Execution::Args::Type::SortAscending, Resource::String::SortAscendingArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::SortDescending, Resource::String::SortDescendingArgumentDescription, ArgumentType::Flag },
};
}
Resource::LocString ListCommand::ShortDescription() const
{
return { Resource::String::ListCommandShortDescription };
}
Resource::LocString ListCommand::LongDescription() const
{
return { Resource::String::ListCommandLongDescription };
}
void ListCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const
{
context <<
Workflow::OpenSource() <<
Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed);
switch (valueType)
{
case Execution::Args::Type::Query:
context <<
Workflow::RequireCompletionWordNonEmpty <<
Workflow::SearchSourceForManyCompletion <<
Workflow::CompleteWithMatchedField;
break;
case Execution::Args::Type::Id:
case Execution::Args::Type::Name:
case Execution::Args::Type::Moniker:
case Execution::Args::Type::Source:
case Execution::Args::Type::Tag:
case Execution::Args::Type::Command:
context <<
Workflow::CompleteWithSingleSemanticsForValueUsingExistingSource(valueType);
break;
}
}
Utility::LocIndView ListCommand::HelpLink() const
{
return "https://aka.ms/winget-command-list"_liv;
}
void ListCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
Argument::ValidateArgumentDependency(execArgs, Execution::Args::Type::IncludeUnknown, Execution::Args::Type::Upgrade);
Argument::ValidateArgumentDependency(execArgs, Execution::Args::Type::IncludePinned, Execution::Args::Type::Upgrade);
}
void ListCommand::ExecuteInternal(Execution::Context& context) const
{
context.SetFlags(Execution::ContextFlag::TreatSourceFailuresAsWarning);
context <<
Workflow::OpenSource() <<
Workflow::OpenCompositeSource(Workflow::DetermineInstalledSource(context)) <<
Workflow::SearchSourceForMany <<
Workflow::HandleSearchResultFailures <<
Workflow::EnsureMatchesFromSearchResult(OperationType::List) <<
Workflow::ReportListResult(context.Args.Contains(Execution::Args::Type::Upgrade));
}
}