Command Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a specific action that the application performs.
public ref class Command : System::CommandLine::Symbol, System::Collections::IEnumerable
public ref class Command : System::CommandLine::Symbol, System::Collections::Generic::IEnumerable<System::CommandLine::Symbol ^>, System::CommandLine::ICommand
public class Command : System.CommandLine.Symbol, System.Collections.IEnumerable
public class Command : System.CommandLine.Symbol, System.Collections.Generic.IEnumerable<System.CommandLine.Symbol>, System.CommandLine.ICommand
type Command = class
inherit Symbol
interface IEnumerable
type Command = class
inherit Symbol
interface ICommand
interface ISymbol
interface ISuggestionSource
interface seq<Symbol>
interface IEnumerable
Public Class Command
Inherits Symbol
Implements IEnumerable
Public Class Command
Inherits Symbol
Implements ICommand, IEnumerable(Of Symbol)
- Inheritance
- Derived
- Implements
Remarks
Use the Command object for actions that correspond to a specific string (the command name). For simple applications that only have one action, see RootCommand. For example, dotnet run uses run as the command.
Constructors
| Name | Description |
|---|---|
| Command(String, String) |
Initializes a new instance of the Command class. |
Properties
| Name | Description |
|---|---|
| Action |
Gets or sets the CommandLineAction for the Command. The handler represents the action that will be performed when the Command is invoked. |
| Aliases |
Gets the unique set of strings that can be used on the command line to specify the command. |
| Aliases | (Inherited from Symbol) |
| Argument | |
| Arguments |
Gets all of the arguments for the command. |
| Children |
Gets the child symbols. |
| Children | (Inherited from Symbol) |
| Description |
Gets or sets the description of the symbol. (Inherited from Symbol) |
| Handler | |
| Hidden |
Gets or sets a value indicating whether the symbol is hidden. (Inherited from Symbol) |
| IsHidden | (Inherited from Symbol) |
| Name |
Gets the name of the symbol. (Inherited from Symbol) |
| Options |
Gets all of the options for the command. |
| Parents |
Gets the parent symbols. (Inherited from Symbol) |
| RawAliases | (Inherited from Symbol) |
| Subcommands |
Gets all of the subcommands for the command. |
| TreatUnmatchedTokensAsErrors |
Gets or sets a value that indicates whether unmatched tokens should be treated as errors. |
| Validators |
Gets the validators to the command. Validators can be used to create custom validation logic. |
Methods
| Name | Description |
|---|---|
| Add(Argument) |
Adds a Argument to the command. |
| Add(Command) |
Adds a Command to the command. |
| Add(Option) |
Adds an Option to the command. |
| Add(Symbol) | |
| AddAlias(String) | |
| AddAliasInner(String) | (Inherited from Symbol) |
| AddArgument(Argument) | |
| AddCommand(Command) | |
| AddOption(Option) | |
| AddValidator(ValidateSymbol<CommandResult>) | |
| ClearAliases() | (Inherited from Symbol) |
| GetCompletions(CompletionContext) |
Gets completions for the symbol. |
| GetEnumerator() | |
| HasAlias(String) | (Inherited from Symbol) |
| HasRawAlias(String) | (Inherited from Symbol) |
| Parse(IReadOnlyList<String>, ParserConfiguration) |
Parses an array strings using the command. |
| Parse(String, ParserConfiguration) |
Parses a command line string value using the command. |
| SetAction(Action<ParseResult>) |
Sets a synchronous action to be run when the command is invoked. |
| SetAction(Func<ParseResult,CancellationToken,Task<Int32>>) |
Sets an asynchronous action when the command is invoked. |
| SetAction(Func<ParseResult,CancellationToken,Task>) |
Sets an asynchronous action to be run when the command is invoked. |
| SetAction(Func<ParseResult,Int32>) |
Sets a synchronous action to be run when the command is invoked. |
| SetAction(Func<ParseResult,Task<Int32>>) |
Sets an asynchronous action to be run when the command is invoked. |
| SetAction(Func<ParseResult,Task>) |
Sets an asynchronous action to be run when the command is invoked. |
| Suggest(String) | (Inherited from Symbol) |
| ToString() |
Returns a string that represents the current object. (Inherited from Symbol) |
Explicit Interface Implementations
| Name | Description |
|---|---|
| ICommand.Argument | |
| ICommand.Arguments | |
| ICommand.Options | |
| IEnumerable.GetEnumerator() |
Returns an enumerator that iterates through a collection. |
| ISymbol.Children | (Inherited from Symbol) |