Repository navigation
Expand file tree
/
Copy pathDotNetCommandDefinition.cs
More file actions
178 lines (161 loc) · 7.35 KB
/
Copy pathDotNetCommandDefinition.cs
File metadata and controls
178 lines (161 loc) · 7.35 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
175
176
177
178
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
using System.CommandLine.Completions;
using System.CommandLine.StaticCompletions;
using Microsoft.DotNet.Cli.Commands.Build;
using Microsoft.DotNet.Cli.Commands.BuildServer;
using Microsoft.DotNet.Cli.Commands.Clean;
using Microsoft.DotNet.Cli.Commands.Dnx;
using Microsoft.DotNet.Cli.Commands.Format;
using Microsoft.DotNet.Cli.Commands.Fsi;
using Microsoft.DotNet.Cli.Commands.Help;
using Microsoft.DotNet.Cli.Commands.Hidden.Add;
using Microsoft.DotNet.Cli.Commands.Hidden.Complete;
using Microsoft.DotNet.Cli.Commands.Hidden.InternalReportInstallSuccess;
using Microsoft.DotNet.Cli.Commands.Hidden.List;
using Microsoft.DotNet.Cli.Commands.Hidden.Parse;
using Microsoft.DotNet.Cli.Commands.Hidden.Remove;
using Microsoft.DotNet.Cli.Commands.MSBuild;
using Microsoft.DotNet.Cli.Commands.New;
using Microsoft.DotNet.Cli.Commands.NuGet;
using Microsoft.DotNet.Cli.Commands.Pack;
using Microsoft.DotNet.Cli.Commands.Package;
using Microsoft.DotNet.Cli.Commands.Project;
using Microsoft.DotNet.Cli.Commands.Publish;
using Microsoft.DotNet.Cli.Commands.Reference;
using Microsoft.DotNet.Cli.Commands.Restore;
using Microsoft.DotNet.Cli.Commands.Run;
using Microsoft.DotNet.Cli.Commands.Run.Api;
using Microsoft.DotNet.Cli.Commands.Sdk;
using Microsoft.DotNet.Cli.Commands.Solution;
using Microsoft.DotNet.Cli.Commands.Test;
using Microsoft.DotNet.Cli.Commands.Tool;
using Microsoft.DotNet.Cli.Commands.Tool.Store;
using Microsoft.DotNet.Cli.Commands.VSTest;
using Microsoft.DotNet.Cli.Commands.Workload;
namespace Microsoft.DotNet.Cli.Commands;
internal sealed class DotNetCommandDefinition : RootCommand
{
// RootCommand names the root command after the running executable, falling back to the
// "System.CommandLine.ExecutableName" AppContext value (emitted by the System.CommandLine build
// targets) and then to "app". Ensure the fallback is "dotnet" when the host provides neither,
// so help usage lines and completion scripts never read "app <command>".
static DotNetCommandDefinition() => EnsureExecutableName();
internal static void EnsureExecutableName()
{
const string ExecutableNameKey = "System.CommandLine.ExecutableName";
if (AppContext.GetData(ExecutableNameKey) is not string { Length: > 0 })
{
AppContext.SetData(ExecutableNameKey, "dotnet");
}
}
public readonly Argument<string> DotnetSubCommand = new("subcommand")
{
Arity = ArgumentArity.ZeroOrOne,
Hidden = true
};
public readonly Option<bool> DiagOption = CommonOptions.CreateDiagnosticsOption(recursive: false);
public readonly Option<bool> VersionOption = new("--version")
{
Arity = ArgumentArity.Zero
};
public readonly Option<bool> InfoOption = new("--info")
{
Arity = ArgumentArity.Zero
};
public readonly Option<bool> CliSchemaOption = new("--cli-schema")
{
Description = CommandDefinitionStrings.SDKSchemaCommandDefinition,
Arity = ArgumentArity.Zero,
Recursive = true,
Hidden = true,
};
public readonly Option<bool> ListSdksOption = new("--list-sdks")
{
Arity = ArgumentArity.Zero
};
public readonly Option<bool> ListRuntimesOption = new("--list-runtimes")
{
Arity = ArgumentArity.Zero
};
public readonly AddCommandDefinition AddCommand;
public readonly BuildCommandDefinition BuildCommand;
public readonly BuildServerCommandDefinition BuildServerCommand;
public readonly CleanCommandDefinition CleanCommand;
public readonly DnxCommandDefinition DnxCommand;
public readonly FormatCommandDefinition FormatCommand;
public readonly CompleteCommandDefinition CompleteCommand;
public readonly FsiCommandDefinition FsiCommand;
public readonly ListCommandDefinition ListCommand;
public readonly MSBuildCommandDefinition MSBuildCommand;
public readonly NewCommandDefinition NewCommand;
public readonly NuGetCommandDefinition NuGetCommand;
public readonly PackCommandDefinition PackCommand;
public readonly PackageCommandDefinition PackageCommand;
public readonly ParseCommandDefinition ParseCommand;
public readonly ProjectCommandDefinition ProjectCommand;
public readonly PublishCommandDefinition PublishCommand;
public readonly ReferenceCommandDefinition ReferenceCommand;
public readonly RemoveCommandDefinition RemoveCommand;
public readonly RestoreCommandDefinition RestoreCommand;
public readonly RunCommandDefinition RunCommand;
public readonly RunApiCommandDefinition RunApiCommand;
public readonly SolutionCommandDefinition SolutionCommand;
public readonly StoreCommandDefinition StoreCommand;
public readonly ToolCommandDefinition ToolCommand;
public readonly VSTestCommandDefinition VSTestCommand;
public readonly HelpCommandDefinition HelpCommand;
public readonly SdkCommandDefinition SdkCommand;
public readonly InternalReportInstallSuccessCommandDefinition InternalReportInstallSuccessCommand;
public readonly WorkloadCommandDefinition WorkloadCommand;
public readonly TestCommandDefinition TestCommand;
public readonly CompletionsCommandDefinition CompletionsCommand;
public DotNetCommandDefinition()
: base("dotnet")
{
Directives.Add(new DiagramDirective());
Directives.Add(new SuggestDirective());
Directives.Add(new EnvironmentVariablesDirective());
Arguments.Add(DotnetSubCommand);
Options.Add(DiagOption);
Options.Add(VersionOption);
Options.Add(InfoOption);
Options.Add(CliSchemaOption);
// Host-handled options. Only defined to be shown in help.
Options.Add(ListSdksOption);
Options.Add(ListRuntimesOption);
Subcommands.Add(AddCommand = new());
Subcommands.Add(BuildCommand = new());
Subcommands.Add(BuildServerCommand = new());
Subcommands.Add(CleanCommand = new());
Subcommands.Add(DnxCommand = new());
Subcommands.Add(FormatCommand = new());
Subcommands.Add(CompleteCommand = new());
Subcommands.Add(FsiCommand = new());
Subcommands.Add(ListCommand = new());
Subcommands.Add(MSBuildCommand = new());
Subcommands.Add(NewCommand = new());
Subcommands.Add(NuGetCommand = new());
Subcommands.Add(PackCommand = new());
Subcommands.Add(PackageCommand = new());
Subcommands.Add(ParseCommand = new());
Subcommands.Add(ProjectCommand = new());
Subcommands.Add(PublishCommand = new());
Subcommands.Add(ReferenceCommand = new());
Subcommands.Add(RemoveCommand = new());
Subcommands.Add(RestoreCommand = new());
Subcommands.Add(RunCommand = new());
Subcommands.Add(RunApiCommand = new());
Subcommands.Add(SolutionCommand = new());
Subcommands.Add(StoreCommand = new());
Subcommands.Add(TestCommand = TestCommandDefinition.Create());
Subcommands.Add(ToolCommand = new());
Subcommands.Add(VSTestCommand = new());
Subcommands.Add(HelpCommand = new());
Subcommands.Add(SdkCommand = new());
Subcommands.Add(InternalReportInstallSuccessCommand = new());
Subcommands.Add(WorkloadCommand = new());
Subcommands.Add(CompletionsCommand = new());
}
}