76 types derived from Command
aspire (1)
Commands\BaseCommand.cs (1)
15internal abstract class BaseCommand : Command
cdac-build-tool (1)
ComposeCommand.cs (1)
11internal sealed class ComposeCommand : Command
Microsoft.DotNet.Cli.Definitions (68)
Commands\Build\BuildCommandDefinition.cs (1)
10internal sealed class BuildCommandDefinition : Command
Commands\BuildServer\BuildServerCommandDefinition.cs (1)
10internal sealed class BuildServerCommandDefinition : Command
Commands\BuildServer\BuildServerShutdownCommandDefinition.cs (1)
8internal sealed class BuildServerShutdownCommandDefinition : Command
Commands\Clean\CleanCommandDefinition.cs (1)
10internal sealed class CleanCommandDefinition : Command
Commands\Clean\CleanFileBasedAppArtifactsCommandDefinition.cs (1)
8internal sealed class CleanFileBasedAppArtifactsCommandDefinition : Command
Commands\Format\FormatCommandDefinition.cs (1)
9internal sealed class FormatCommandDefinition : Command
Commands\Fsi\FsiCommandDefinition.cs (1)
9internal sealed class FsiCommandDefinition : Command
Commands\Help\HelpCommandDefinition.cs (1)
9internal sealed class HelpCommandDefinition : Command
Commands\Hidden\Add\AddCommandDefinition.cs (1)
12internal sealed class AddCommandDefinition : Command
Commands\Hidden\Complete\CompleteCommandDefinition.cs (1)
8internal sealed class CompleteCommandDefinition : Command
Commands\Hidden\InternalReportInstallSuccess\InternalReportInstallSuccessCommandDefinition.cs (1)
8internal sealed class InternalReportInstallSuccessCommandDefinition : Command
Commands\Hidden\List\ListCommandDefinition.cs (1)
11internal sealed class ListCommandDefinition : Command
Commands\Hidden\List\ListReferenceCommandDefinition.cs (1)
25internal abstract class ListReferenceCommandDefinitionBase : Command
Commands\Hidden\Parse\ParseCommandDefinition.cs (1)
8internal sealed class ParseCommandDefinition : Command
Commands\Hidden\Remove\RemoveCommandDefinition.cs (1)
12internal sealed class RemoveCommandDefinition : Command
Commands\MSBuild\MSBuildCommandDefinition.cs (1)
9internal sealed class MSBuildCommandDefinition : Command
Commands\New\InstantiateCommandDefinition.cs (1)
8public sealed class NewCreateCommandDefinition : Command
Commands\New\NewAliasCommandDefinition.cs (1)
9: Command(name, description)
Commands\New\NewCommandDefinition.cs (1)
11public sealed class NewCommandDefinition : Command
Commands\New\NewDetailsCommandDefinition.cs (1)
8public sealed class NewDetailsCommandDefinition : Command
Commands\New\NewInstallCommandDefinition.cs (1)
8public sealed class NewInstallCommandDefinition : Command
Commands\New\NewListCommandDefinition.cs (1)
8public sealed class NewListCommandDefinition : Command
Commands\New\NewSearchCommandDefinition.cs (1)
8public sealed class NewSearchCommandDefinition : Command
Commands\New\NewUninstallCommandDefinition.cs (1)
8public sealed class NewUninstallCommandDefinition : Command
Commands\New\NewUpdateCommandDefinition.cs (1)
8public abstract class NewUpdateCommandDefinitionBase : Command
Commands\NuGet\NuGetCommandDefinition.cs (8)
10internal sealed class NuGetCommandDefinition : Command 50public sealed class NuGetDeleteCommandDefinition : Command 92public sealed class NuGetLocalsCommandDefinition : Command 125public sealed class NuGetPushCommandDefinition : Command 191public sealed class NuGetVerifyCommandDefinition : Command 222public sealed class NuGetTrustCommandDefinition : Command 259public abstract class NuGetTrustSubcommandDefinition : Command 356public sealed class NuGetSignCommandDefinition : Command
Commands\Pack\PackCommandDefinition.cs (1)
12internal sealed class PackCommandDefinition : Command
Commands\Package\PackageAddCommandDefinition.cs (1)
18public abstract class PackageAddCommandDefinitionBase : Command
Commands\Package\PackageCommandDefinition.cs (1)
14internal sealed class PackageCommandDefinition : Command
Commands\Package\PackageListCommandDefinition.cs (1)
17internal abstract class PackageListCommandDefinitionBase : Command
Commands\Package\PackageRemoveCommandDefinition.cs (1)
24internal abstract class PackageRemoveCommandDefinitionBase : Command
Commands\Package\PackageSearchCommandDefinition.cs (1)
9internal sealed class PackageSearchCommandDefinition : Command
Commands\Project\ProjectCommandDefinition.cs (1)
9internal sealed class ProjectCommandDefinition : Command
Commands\Project\ProjectConvertCommandDefinition.cs (1)
8internal sealed class ProjectConvertCommandDefinition : Command
Commands\Publish\PublishCommandDefinition.cs (1)
10internal sealed class PublishCommandDefinition : Command
Commands\Reference\ReferenceAddCommandDefinition.cs (1)
20internal abstract class ReferenceAddCommandDefinitionBase : Command
Commands\Reference\ReferenceCommandDefinition.cs (1)
12internal sealed class ReferenceCommandDefinition : Command
Commands\Reference\ReferenceRemoveCommandDefinition.cs (1)
18internal abstract class ReferenceRemoveCommandDefinitionBase : Command
Commands\Restore\RestoreCommandDefinition.cs (1)
10internal sealed class RestoreCommandDefinition : Command
Commands\Run\RunApiCommandDefinition.cs (1)
8internal sealed class RunApiCommandDefinition : Command
Commands\Run\RunCommandDefinition.cs (1)
10internal sealed class RunCommandDefinition : Command
Commands\Sdk\SdkCheckCommandDefinition.cs (1)
9: Command("check", CommandDefinitionStrings.SdkCheckAppFullName)
Commands\Sdk\SdkCommandDefinition.cs (1)
10internal sealed class SdkCommandDefinition : Command
Commands\Solution\SolutionAddCommandDefinition.cs (1)
8public sealed class SolutionAddCommandDefinition : Command
Commands\Solution\SolutionCommandDefinition.cs (1)
13public sealed class SolutionCommandDefinition : Command
Commands\Solution\SolutionListCommandDefinition.cs (1)
8public sealed class SolutionListCommandDefinition : Command
Commands\Solution\SolutionMigrateCommandDefinition.cs (1)
8public sealed class SolutionMigrateCommandDefinition : Command
Commands\Solution\SolutionRemoveCommandDefinition.cs (1)
8public sealed class SolutionRemoveCommandDefinition : Command
Commands\Test\TestCommandDefinition.cs (1)
12internal abstract partial class TestCommandDefinition : Command
Commands\Tool\StoreCommandDefinition.cs (1)
9internal sealed class StoreCommandDefinition : Command
Commands\Tool\ToolCommandDefinition.cs (1)
17internal sealed class ToolCommandDefinition : Command
Commands\Tool\ToolExecuteCommandDefinition.cs (1)
17internal abstract class ToolExecuteCommandDefinitionBase : Command
Commands\Tool\ToolListCommandDefinition.cs (1)
8internal sealed class ToolListCommandDefinition : Command
Commands\Tool\ToolRestoreCommandDefinition.cs (1)
8internal sealed class ToolRestoreCommandDefinition : Command
Commands\Tool\ToolRunCommandDefinition.cs (1)
10internal sealed class ToolRunCommandDefinition : Command
Commands\Tool\ToolSearchCommandDefinition.cs (1)
8internal sealed class ToolSearchCommandDefinition : Command
Commands\Tool\ToolUninstallCommandDefinition.cs (1)
8internal sealed class ToolUninstallCommandDefinition : Command
Commands\Tool\ToolUpdateInstallCommandDefinition.cs (1)
9internal abstract class ToolUpdateInstallCommandDefinition : System.CommandLine.Command
Commands\VSTest\VSTestCommandDefinition.cs (1)
9internal sealed class VSTestCommandDefinition : Command
Commands\Workload\WorkloadCommandDefinition.cs (1)
21internal sealed class WorkloadCommandDefinition : Command
Commands\Workload\WorkloadCommandDefinitionBase.cs (1)
10: Command(name, description)
Microsoft.TemplateEngine.Cli (2)
Commands\BaseCommand.cs (1)
24: Command(definition.Name, definition.Description)
Commands\create\TemplateCommand.cs (1)
18internal class TemplateCommand : Command
NuGet.CommandLine.XPlat (1)
Commands\DocumentedCommand.cs (1)
10public class DocumentedCommand : Command
System.CommandLine (1)
RootCommand.cs (1)
21public class RootCommand : Command
System.CommandLine.StaticCompletions (2)
CompletionsCommandDefinition.cs (1)
8public sealed class CompletionsCommandDefinition : Command
CompletionsGenerateScriptCommandDefinition.cs (1)
8public sealed class CompletionsGenerateScriptCommandDefinition : Command
30 instantiations of Command
Aspire.Cli.Tests (2)
Commands\OptionWithLegacyTests.cs (2)
16var command = new Command("test"); 31var command = new Command("test");
aspire-managed (3)
NuGet\Commands\LayoutCommand.cs (1)
21var command = new Command("layout", "Create flat DLL layout from project.assets.json");
NuGet\Commands\RestoreCommand.cs (1)
28var command = new Command("restore", "Restore NuGet packages");
NuGet\Commands\SearchCommand.cs (1)
25var command = new Command("search", "Search for NuGet packages");
dotnet-format (3)
Commands\FormatAnalyzersCommand.cs (1)
18var command = new Command("analyzers", Resources.Run_3rd_party_analyzers__and_apply_fixes)
Commands\FormatStyleCommand.cs (1)
18var command = new Command("style", Resources.Run_code_style_analyzers_and_apply_fixes)
Commands\FormatWhitespaceCommand.cs (1)
18var command = new Command("whitespace", Resources.Run_whitespace_formatting)
dotnet-sourcelink (4)
dotnet-suggest (4)
SuggestionDispatcher.cs (4)
25CompleteScriptCommand = new Command("script", "Print complete script for specific shell") 34ListCommand = new Command("list") 44GetCommand = new Command("get", "Gets suggestions from the specified executable") 53RegisterCommand = new Command("register", "Registers an app for suggestions")
Microsoft.DotNet.Cli.Utils (1)
MSBuildArgs.cs (1)
105var fakeCommand = new System.CommandLine.Command("dotnet");
Microsoft.DotNet.MacOsPkg.Cli (3)
Program.cs (3)
43var unpackCommand = new Command("unpack", "Unpack a .pkg or .app file") 56var packCommand = new Command("pack", "Pack a directory into a .pkg or .app file.") 68var verifyCommand = new Command("verify", "Verify that a pkg or app is signed.")
Microsoft.DotNet.VersionTools.Cli (1)
Program.cs (1)
40System.CommandLine.Command trimAssetVersionCommand = new("trim-assets-version", "Trim versions from provided assets. Currently, only NuGet packages are supported.");
Microsoft.Extensions.AI.Evaluation.Console (3)
Program.cs (3)
56var reportCmd = new Command("report", "Generate a report from a result store"); 132var cleanResultsCmd = new Command("clean-results", "Delete results"); 149var cleanCacheCmd = new Command("clean-cache", "Delete expired cache entries");
Microsoft.NET.Sdk.BlazorWebAssembly.Tool (1)
Program.cs (1)
16Command brotli = new("brotli");
Microsoft.NET.Sdk.StaticWebAssets.Tool (1)
Program.cs (1)
16Command brotli = new("brotli");
Microsoft.TemplateEngine.Cli (1)
Commands\create\InstantiateCommand.NoMatchHandling.cs (1)
177Command reparseCommand = new("reparse-only")
NuGet.CommandLine.XPlat (3)
NuGetCommands.cs (1)
32packageCommand = new Command("package");
Program.cs (2)
116var packageCommand = new Command("package"); 127var nugetCommand = new Command("nuget");
327 references to Command
aspire (28)
Backchannel\AuxiliaryBackchannelMonitor.cs (1)
142var command = await executionContext.CommandSelected.Task.WaitAsync(combined.Token).ConfigureAwait(false);
CliExecutionContext.cs (3)
54private Command? _command; 59public Command? Command 75public TaskCompletionSource<Command> CommandSelected { get; } = new();
Commands\AppHostLauncher.cs (1)
57internal static void AddLaunchOptions(Command command)
Commands\GroupedHelpAction.cs (1)
15internal sealed class GroupedHelpAction(Command rootCommand, IAnsiConsole ansiConsole) : SynchronousCommandLineAction
Commands\GroupedHelpWriter.cs (7)
33public static void WriteHelp(Command command, TextWriter writer, int? maxWidth = null) 51var ungroupedCommands = new List<Command>(); 53foreach (var sub in command.Subcommands) 96foreach (var cmd in ungroupedCommands) 133foreach (var cmd in ungroupedCommands.OrderBy(c => c.Name, StringComparer.OrdinalIgnoreCase)) 255private static string FormatCommandLabel(Command cmd) 261private static string GetArgumentSyntax(Command cmd)
NuGet\NuGetPackagePrefetcher.cs (7)
9using SystemCommand = System.CommandLine.Command; 18var command = await WaitForCommandSelectionAsync(stoppingToken); 71private async Task<SystemCommand?> WaitForCommandSelectionAsync(CancellationToken cancellationToken) 80var command = await executionContext.CommandSelected.Task.WaitAsync(combined.Token); 90private static bool ShouldPrefetchTemplatePackages(SystemCommand? command) 103private static bool ShouldPrefetchCliPackages(SystemCommand? command) 115private static bool IsRuntimeOnlyCommand(SystemCommand command)
Templating\CallbackTemplate.cs (2)
12Action<Command> applyOptionsCallback, 30public void ApplyOptions(Command command)
Templating\CliTemplateFactory.cs (1)
158private static void AddOptionIfMissing(System.CommandLine.Command command, System.CommandLine.Option option)
Templating\DotNetTemplateFactory.cs (4)
419private void ApplyExtraAspireStarterOptions(Command command) 428private void ApplyExtraAspireJsFrontendStarterOptions(Command command) 435private void ApplyDevLocalhostTldOption(Command command) 440private static void AddOptionIfMissing(Command command, Option option)
Templating\ITemplate.cs (1)
47void ApplyOptions(Command command);
Aspire.Cli.Tests (12)
Commands\McpCommandTests.cs (9)
64var mcpCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "mcp"); 78var mcpCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "mcp"); 81var startCommand = mcpCommand.Subcommands.FirstOrDefault(c => c.Name == "start"); 94var mcpCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "mcp"); 165var agentCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "agent"); 180var agentCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "agent"); 183var mcpCommand = agentCommand.Subcommands.FirstOrDefault(c => c.Name == "mcp"); 196var agentCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "agent"); 199var initCommand = agentCommand.Subcommands.FirstOrDefault(c => c.Name == "init");
Commands\OptionWithLegacyTests.cs (2)
16var command = new Command("test"); 31var command = new Command("test");
Commands\RootCommandTests.cs (1)
461foreach (var sub in visibleCommands)
aspire-managed (6)
NuGet\Commands\LayoutCommand.cs (2)
19public static Command Create() 21var command = new Command("layout", "Create flat DLL layout from project.assets.json");
NuGet\Commands\RestoreCommand.cs (2)
26public static Command Create() 28var command = new Command("restore", "Restore NuGet packages");
NuGet\Commands\SearchCommand.cs (2)
23public static Command Create() 25var command = new Command("search", "Search for NuGet packages");
dotnet (30)
CliSchema.cs (6)
14using Command = System.CommandLine.Command; 82var command = parseResult.CommandResult.Command; 106private static RootCommandDetails CreateRootCommandDetails(Command command) 152private static Dictionary<string, CommandDetails>? CreateSubcommandsDictionary(IList<Command> subcommands) 159foreach (var subcommand in subcommands.OrderBy(c => c.Name, StringComparer.OrdinalIgnoreCase)) 177private static CommandDetails CreateCommandDetails(Command subCommand) => new CommandDetails(
CommandBase.cs (1)
32where TDefinition : Command
Commands\DotNetCommandFactory.cs (2)
38var command = Parser.GetBuiltInCommand(commandName); 50System.CommandLine.Command commandDefinition,
Commands\New\NewCommandParser.cs (2)
19using Command = System.CommandLine.Command; 30public static Command ConfigureCommand(NewCommandDefinition definition)
Commands\NuGet\NuGetCommandParser.cs (2)
10public static void ConfigureCommand(Command command) 14foreach (var subcommand in command.Subcommands)
Commands\Test\MTP\MicrosoftTestingPlatformTestCommand.Help.cs (6)
56private static IEnumerable<string> GetCustomUsageParts(Command command, bool showOptions = true, bool showPlatformOptions = true, bool showExtensionOptions = true) 58var parentCommands = new List<Command>(); 59var nextCommand = command; 63nextCommand = nextCommand.Parents.FirstOrDefault(c => c is Command) as Command; 67foreach (var parentCommand in parentCommands)
Commands\Workload\WorkloadCommandParser.cs (1)
20using Command = System.CommandLine.Command;
Parser.cs (9)
94using Command = System.CommandLine.Command; 192public static Command? GetBuiltInCommand(string commandName) => 341var command = context.Command; 395Command? listCommand = command.Parents.Single() as Command; 426private static bool IsInNuGetCommandTree(Command command) 428Command? current = command; 435current = current.Parents.FirstOrDefault(p => p is Command) as Command;
ParserOptionActions.cs (1)
97var command = parseResult.CommandResult.Command;
dotnet-format (7)
Commands\FormatAnalyzersCommand.cs (2)
16internal static Command GetCommand() 18var command = new Command("analyzers", Resources.Run_3rd_party_analyzers__and_apply_fixes)
Commands\FormatCommandCommon.cs (1)
118public static void AddCommonOptions(this Command command)
Commands\FormatStyleCommand.cs (2)
16internal static Command GetCommand() 18var command = new Command("style", Resources.Run_code_style_analyzers_and_apply_fixes)
Commands\FormatWhitespaceCommand.cs (2)
16internal static Command GetCommand() 18var command = new Command("whitespace", Resources.Run_whitespace_formatting)
dotnet-sourcelink (4)
dotnet-suggest (4)
SuggestionDispatcher.cs (4)
76private Command CompleteScriptCommand { get; } 78private Command GetCommand { get; } 92private Command ListCommand { get; } 100private Command RegisterCommand { get; }
dotnet-watch (5)
CommandLine\CommandLineOptions.cs (5)
54public required Command Command { get; init; } 77var command = GetSubcommand(parseResult, out bool isExplicitCommand); 197Command command, 331private static Command GetSubcommand(ParseResult parseResult, out bool isExplicit) 343if (knownCommandsByName.TryGetValue(parseResult.UnmatchedTokens[i], out var explicitCommand))
Microsoft.DotNet.Cli.CommandLine (2)
ForwardedOptionExtensions.cs (2)
207public IEnumerable<string> OptionValuesToBeForwarded(Command? command = null) 224public IEnumerable<string> ForwardedOptionValues(Command command, string alias)
Microsoft.DotNet.Cli.Definitions (29)
Commands\Clean\CleanCommandDefinition.cs (1)
46public readonly Command FileBasedAppsCommand = new CleanFileBasedAppArtifactsCommandDefinition();
Commands\New\CommandDefinitionExtensions.cs (3)
12where TDefinition : Command 29where TDefinition : Command 51where TDefinition : Command
Commands\Package\PackageCommandDefinition.cs (1)
10using Command = System.CommandLine.Command;
Commands\Test\TestCommandDefinition.cs (1)
8using Command = System.CommandLine.Command;
Commands\Workload\WorkloadCommandDefinition.cs (1)
17using Command = System.CommandLine.Command;
Help\HelpBuilder.cs (9)
191if (symbol is Option or Command) 209: Default.GetCommandUsageLabel((Command)symbol)); 268case Command command: 385private string GetUsage(Command command) 393IEnumerable<Command> parentCommands = 394RecurseWhileNotNull(command, c => c.Parents.OfType<Command>().FirstOrDefault()) 397foreach (var parentCommand in parentCommands) 433private IEnumerable<TwoColumnHelpRow> GetCommandArgumentRows(Command command, HelpContext context) => 434RecurseWhileNotNull(command, c => c.Parents.OfType<Command>().FirstOrDefault())
Help\HelpBuilder.Default.cs (6)
91public static string GetCommandUsageLabel(Command symbol) 94/// <inheritdoc cref="GetCommandUsageLabel(Command)"/> 175Command? current = ctx.Command; 178Command? parentCommand = null; 181if ((parentCommand = parent as Command) is not null) 215/// Writes a help section describing a command's additional arguments, typically shown only when <see cref="Command.TreatUnmatchedTokensAsErrors"/> is set to <see langword="true"/>.
Help\HelpContext.cs (2)
17Command command, 31public Command Command { get; } = command ?? throw new ArgumentNullException(nameof(command));
Help\ICustomHelp.cs (1)
9/// If <see cref="Command"/> implements this interface, it can create custom help
Utilities\CommandExtensions.cs (4)
10public static Command GetRootCommand(this Command command) 11=> command.Parents.FirstOrDefault(p => p is Command) is Command parentCommand ? GetRootCommand(parentCommand) : command;
Microsoft.DotNet.Cli.Utils (1)
MSBuildArgs.cs (1)
105var fakeCommand = new System.CommandLine.Command("dotnet");
Microsoft.DotNet.MacOsPkg.Cli (3)
Program.cs (3)
43var unpackCommand = new Command("unpack", "Unpack a .pkg or .app file") 56var packCommand = new Command("pack", "Pack a directory into a .pkg or .app file.") 68var verifyCommand = new Command("verify", "Verify that a pkg or app is signed.")
Microsoft.DotNet.VersionTools.Cli (1)
Program.cs (1)
40System.CommandLine.Command trimAssetVersionCommand = new("trim-assets-version", "Trim versions from provided assets. Currently, only NuGet packages are supported.");
Microsoft.Extensions.AI.Evaluation.Console (3)
Program.cs (3)
56var reportCmd = new Command("report", "Generate a report from a result store"); 132var cleanResultsCmd = new Command("clean-results", "Delete results"); 149var cleanCacheCmd = new Command("clean-cache", "Delete expired cache entries");
Microsoft.NET.Sdk.BlazorWebAssembly.Tool (1)
Program.cs (1)
16Command brotli = new("brotli");
Microsoft.NET.Sdk.StaticWebAssets.Tool (1)
Program.cs (1)
16Command brotli = new("brotli");
Microsoft.TemplateEngine.Cli (57)
Commands\BaseCommand.cs (8)
19using Command = System.CommandLine.Command; 25where TDefinition : Command 29protected static readonly Dictionary<string, Func<Func<ParseResult, ITemplateEngineHost>, Command, Command>> SubcommandFactories = new() 72where TDefinition : Command 87foreach (var subcommandDef in definition.Subcommands) 136where TDeprecatedCommand : Command 137where TNewCommand : Command
Commands\BaseFilterableArgs.cs (1)
10where TDefinition : Command
Commands\create\InstantiateCommand.cs (1)
414System.CommandLine.Command parser = ParserFactory.CreateParser(command);
Commands\create\InstantiateCommand.Help.cs (12)
12using Command = System.CommandLine.Command; 369internal static void ShowUsage(Command? command, IReadOnlyList<string> shortNames, HelpContext context) 378command = command.Parents.FirstOrDefault(c => c is Command) as Command; 442private static void WriteCustomInstantiateHelp(HelpContext context, Command command) 462private static void CustomUsageSection(HelpContext context, Command command) 475Command command, 480List<Command> parentCommands = new(); 481Command? nextCommand = command; 485nextCommand = nextCommand.Parents.FirstOrDefault(c => c is Command) as Command; 489foreach (Command parentCommand in parentCommands)
Commands\create\InstantiateCommand.NoMatchHandling.cs (2)
10using Command = System.CommandLine.Command; 177Command reparseCommand = new("reparse-only")
Commands\create\InstantiateCommand.TabCompletion.cs (1)
63System.CommandLine.Command parser = ParserFactory.CreateParser(command);
Commands\create\InstantiateCommandArgs.cs (1)
71public Command NewOrInstantiateCommand => ParseResult.CommandResult.Command;
Commands\create\TemplateCommand.cs (5)
14using Command = System.CommandLine.Command; 24private readonly Command _instantiateCommand; 33Command instantiateCommand, 295static void AddReservedNamesAndAliases(HashSet<string> reservedAliases, Command command) 305foreach (Command subCommand in command.Subcommands)
Commands\create\TemplateCommandArgs.cs (6)
14public TemplateCommandArgs(TemplateCommand command, Command parentCommand, ParseResult parseResult) 83public Command Command => _command; 87public Command ParentCommand { get; } 126private NewCommand GetRootCommand(Command command) 132Command? currentCommand = command; 135currentCommand = currentCommand.Parents.OfType<Command>().SingleOrDefault();
Commands\Example.cs (17)
12internal static Example<T> For<T>(ParseResult parseResult) where T : Command 37Command? nextCommand = siblingCommand; 41nextCommand = nextCommand.Parents.OfType<Command>().FirstOrDefault(); 47private static T SearchForSiblingCommand<T>(Command currentCommand) where T : Command 49Command? next = currentCommand; 50Command root = currentCommand; 55next = next?.Parents.OfType<Command>().FirstOrDefault(); 58Queue<Command> probes = new(); 62Command current = probes.Dequeue(); 67foreach (var child in current.Subcommands) 75internal static Example<T> FromExistingTokens<T>(ParseResult parseResult) where T : Command 91where T : Command 126where TSubcommand : Command 132public Example<TSubcommand> WithSubcommand<TSubcommand>() where TSubcommand : Command 140internal Example<Command> WithSubcommand(string token) 142var subcommand = currentCommand.Subcommands.FirstOrDefault(c => c.Name.Equals(token) || c.Aliases.Contains(token))
Commands\ParserFactory.cs (2)
16internal static Command CreateParser(Command command, bool disableHelp = false)
NewCommandFactory.cs (1)
12public static Command Create(Func<ParseResult, ICliTemplateEngineHost> hostBuilder, NewCommandDefinition definition)
NuGet.CommandLine.XPlat (20)
Commands\ConfigCommands\ConfigCommand.cs (6)
89internal static Command Register(Command app, Func<ILogger> getLogger) 133private static void RegisterOptionsForCommandConfigPaths(Command cmd, Func<ILogger> getLogger) 150private static void RegisterOptionsForCommandConfigGet(Command cmd, Func<ILogger> getLogger) 172private static void RegisterOptionsForCommandConfigSet(Command cmd, Func<ILogger> getLogger) 193private static void RegisterOptionsForCommandConfigUnset(Command cmd, Func<ILogger> getLogger)
Commands\Package\Download\PackageDownloadCommand.cs (2)
16internal static void Register(Command packageCommand, Option<bool> interactiveOption) 21public static void Register(Command packageCommand, Option<bool> interactiveOption, Func<PackageDownloadArgs, CancellationToken, Task<int>> action)
Commands\Package\Update\PackageUpdateCommand.cs (2)
18internal static void Register(Command packageCommand, Option<bool> interactiveOption, IVirtualProjectBuilder? virtualProjectBuilder = null) 23internal static void Register(Command packageCommand, Option<bool> interactiveOption, Func<PackageUpdateArgs, CancellationToken, Task<int>> action)
Commands\PackageSearch\PackageSearchCommand.cs (2)
21public static void Register(Command rootCommand, Func<ILoggerWithColor> getLogger) 26public static void Register(Command rootCommand, Func<ILoggerWithColor> getLogger, Func<PackageSearchArgs, string, CancellationToken, Task<int>> setupSettingsAndRunSearchAsync)
Commands\Why\WhyCommand.cs (5)
29internal static void Register(Command rootCommand, Lazy<IAnsiConsole> console, IVirtualProjectBuilder? virtualProjectBuilder = null) 41public static void GetWhyCommand(Command rootCommand, IVirtualProjectBuilder? virtualProjectBuilder = null) 49public static void GetWhyCommand(Command rootCommand) 54internal static void Register(Command rootCommand, Lazy<IAnsiConsole> console, Func<WhyCommandRunner> getCommandRunner) 61internal static void Register(Command rootCommand, Lazy<IAnsiConsole> console, Func<WhyCommandArgs, Task<int>> action)
NuGetCommands.cs (1)
29var packageCommand = rootCommand.Subcommands.FirstOrDefault(c => c.Name == "package");
Program.cs (2)
116var packageCommand = new Command("package"); 127var nugetCommand = new Command("nuget");
System.CommandLine (75)
Argument.cs (3)
13/// A symbol defining a value that can be passed on the command line to a <see cref="Command">command</see> or <see cref="Option">option</see>. 143var command = Parents.FlattenBreadthFirst(x => x.Parents) 144.OfType<Command>()
ArgumentArity.cs (2)
152return parent is Command 157if (parent is Command &&
ChildSymbolList{T}.cs (2)
15private readonly Command _parent; 17public ChildSymbolList(Command parent)
Command.cs (7)
30private ChildSymbolList<Command>? _subcommands; 48foreach (var command in Subcommands) 79public IList<Command> Subcommands => _subcommands ??= new(this); 229/// Adds a <see cref="Command"/> to the command. 232public void Add(Command command) => Subcommands.Add(command); 308Command parentCommand = (Command)parent.Symbol;
Help\HelpBuilder.cs (9)
113public void Write(Command command, TextWriter writer) 118private string GetUsage(Command command) 126IEnumerable<Command> parentCommands = 128.RecurseWhileNotNull(c => c.Parents.OfType<Command>().FirstOrDefault()) 131foreach (var parentCommand in parentCommands) 167private IEnumerable<TwoColumnHelpRow> GetCommandArgumentRows(Command command, HelpContext context) => 169.RecurseWhileNotNull(c => c.Parents.OfType<Command>().FirstOrDefault()) 413if (symbol is Option or Command) 431: Default.GetCommandUsageLabel((Command)symbol));
Help\HelpBuilder.Default.cs (6)
127public static string GetCommandUsageLabel(Command symbol) 130/// <inheritdoc cref="GetCommandUsageLabel(Command)"/> 247Command? current = ctx.Command; 250Command? parentCommand = null; 253if ((parentCommand = parent as Command) is not null) 287/// Writes a help section describing a command's additional arguments, typically shown only when <see cref="Command.TreatUnmatchedTokensAsErrors"/> is set to <see langword="true"/>.
Help\HelpBuilderExtensions.cs (1)
17case Command command:
Help\HelpContext.cs (2)
18Command command, 34public Command Command { get; }
Help\HelpOption.cs (2)
16/// When added to a <see cref="Command"/>, it configures the application to show help when one of the following options are specified on the command line: 30/// When added to a <see cref="Command"/>, it configures the application to show help when given name or one of the aliases are specified on the command line.
Invocation\ParseErrorAction.cs (3)
116Command targetSymbol = commandResult.Command; 121? targetSymbol.Children.Where(x => !x.Hidden && x is Option or Command) 133AliasSet? aliasSet = symbol is Option option ? option._aliases : ((Command)symbol)._aliases;
ParseResult.cs (1)
191public CommandResult? GetResult(Command command) =>
Parsing\ArgumentResult.cs (1)
87throw new NotSupportedException($"{nameof(OnlyTake)} is supported only for a {nameof(Command)}-owned {nameof(ArgumentResult)}");
Parsing\CommandLineParser.cs (3)
21public static ParseResult Parse(Command command, IReadOnlyList<string> args, ParserConfiguration? configuration = null) 32public static ParseResult Parse(Command command, string commandLine, ParserConfiguration? configuration = null) 139Command command,
Parsing\CommandResult.cs (2)
15Command command, 28public Command Command { get; }
Parsing\ParseDiagramAction.cs (1)
72argumentResult.Argument.FirstParent!.Symbol is Command { HasArguments: true, Arguments.Count: > 1 };
Parsing\ParseOperation.cs (5)
23private readonly Command _rootCommand; 27Command rootCommand, 79Command command = (Command)CurrentToken.Symbol!; 465if (symbol is Command { Action: { } commandAction } command)
Parsing\StringExtensions.cs (12)
30Command rootCommand, 40var currentCommand = rootCommand; 144Command cmd = (Command)token.Symbol!; 183Token CommandArgument(string value, Command command) => new(value, TokenType.Argument, command, i); 187Token Command(string value, Command cmd) => new(value, TokenType.Command, cmd, i); 269private static bool FirstArgumentIsRootCommand(IReadOnlyList<string> args, Command rootCommand, bool inferRootCommand) 380private static Dictionary<string, Token> ValidTokens(this Command command) 415Command? current = command; 418Command? parentCommand = null; 422if ((parentCommand = parent.Symbol as Command) is not null) 445static void AddCommandTokens(Dictionary<string, Token> tokens, Command cmd)
Parsing\SymbolResult.cs (1)
77public CommandResult? GetResult(Command command) => SymbolResultTree.GetResult(command);
Parsing\SymbolResultTree.cs (6)
10private readonly Command? _rootCommand; 16Command? rootCommand = null, 37internal CommandResult? GetResult(Command command) 105private void PopulateSymbolsByName(Command command) 127var childCommand = command.Subcommands[i]; 133void AddToSymbolsByName(Symbol symbol, Command parent)
Parsing\TokenType.cs (1)
20/// <see cref="CommandLine.Command"/>
RootCommand.cs (1)
19/// use any subcommands. See <see cref="Command"/> for applications with multiple actions.
SymbolNode.cs (2)
8internal SymbolNode(Symbol symbol, Command? parent = null) 16internal Command? Parent { get; }
VersionOption.cs (2)
22/// When added to a <see cref="Command"/>, it enables the use of a <c>--version</c> option, which, when specified in command line input, short circuits normal command handling and instead writes out version information before exiting. 32/// When added to a <see cref="Command"/>, it enables the use of a provided option name and aliases, which, when specified in command line input, short circuits normal command handling and instead writes out version information before exiting.
System.CommandLine.StaticCompletions (38)
HelpGenerationExtensions.cs (7)
18public static string FunctionName(this Command command, string[]? parentCommandNames = null) => parentCommandNames switch 64public static string[] Names(this Command command) 76public static IEnumerable<Option> HierarchicalOptions(this Command c) 87return myOptions.Concat(c.Parents.OfType<Command>().SelectMany(OptionsForParent)).DistinctBy(o => o.Name); 91private static IEnumerable<Option> OptionsForParent(Command c) 100foreach (var p in c.Parents.OfType<Command>())
shells\BashShellProvider.cs (4)
21public string GenerateCompletions(Command command) 33private string GenerateCommandsCompletions(string[] parentCommandNames, Command command, bool isNestedCommand) 102foreach (var subcommand in visibleSubcommands) 161internal static string? GenerateOptionHandlers(Command command)
shells\FishShellProvider.cs (11)
21public string GenerateCompletions(Command command) 32var states = new List<(int id, Command cmd)>(); 61private static void CollectStates(Command cmd, List<(int id, Command cmd)> states) 64foreach (var sub in cmd.Subcommands.Where(c => !c.Hidden)) 90private static void WriteStateWalker(IndentedTextWriter writer, List<(int id, Command cmd)> states, Dictionary<Command, int> stateIdByCommand) 118foreach (var sub in visibleSubs) 211private static void WriteOptionValueCompletions(IndentedTextWriter writer, List<(int id, Command cmd)> states) 314private static void WriteStateCompletions(IndentedTextWriter writer, List<(int id, Command cmd)> states) 325foreach (var sub in cmd.Subcommands.Where(c => !c.Hidden))
shells\NuShellShellProvider.cs (1)
48public string GenerateCompletions(System.CommandLine.Command command) => _dynamicCompletionScript;
shells\PowershellShellProvider.cs (5)
22public string GenerateCompletions(Command command) 147internal static void GenerateSubcommandCompletions(string[] parentCommandNames, IndentedTextWriter writer, Command command) 160foreach (var subcommand in command.Subcommands) 174private static void GenerateStaticCompletionsForCommand(string[] commandPath, Command command, IndentedTextWriter writer) 188foreach (var subcommand in command.Subcommands)
shells\ShellProvider.cs (1)
32string GenerateCompletions(System.CommandLine.Command command);
shells\ZshShellProvider.cs (9)
20public string GenerateCompletions(Command command) 78private static void GenerateOptionsAndArgumentsForCommand(string[] commandPathForThisCommand, Command command, IndentedTextWriter writer) 181private static void GenerateSubcommandList(string[] pathToCurrentCommand, Command command, IndentedTextWriter writer) 196var parentArguments = command.Parents.OfType<Command>().SelectMany(parent => parent.Arguments).Select(arg => arg.Name).ToHashSet(); 204foreach (var subcommand in command.Subcommands.Where(c => !c.Hidden)) 243private static void GenerateSubcommandHandlers(string[] pathToThisCommand, Command command, IndentedTextWriter writer) 256foreach (var subcommand in command.Subcommands.Where(s => !s.Hidden)) 273foreach (var subcommand in command.Subcommands.Where(c => !c.Hidden)) 375private static string[] AppendCommandToPath(string[] path, Command command) =>