Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Command Class
Definition
- Namespace:
- System.CommandLine
- Assembly:
- System.CommandLine.dll
- Package:
- System.CommandLine v3.0.0-preview.5.26302.115
- Source:
- Command.cs
- Source:
- Command.cs
- Source:
- Command.cs
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 class Command : System.CommandLine.Symbol, System.Collections.IEnumerable
type Command = class
inherit Symbol
interface IEnumerable
Public Class Command
Inherits Symbol
Implements IEnumerable
- 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. |
| Arguments |
Gets all of the arguments for the command. |
| Children |
Gets the child symbols. |
| Description |
Gets or sets the description of the symbol. (Inherited from Symbol) |
| Hidden |
Gets or sets a value indicating whether the symbol is hidden. (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) |
| 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. |
| GetCompletions(CompletionContext) |
Gets completions for the 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. |
| ToString() |
Returns a string that represents the current object. (Inherited from Symbol) |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IEnumerable.GetEnumerator() |
Returns an enumerator that iterates through a collection. |
Applies to
Feedback
Was this page helpful?
