Kieli

Command Class

Definition

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
Command
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)

Extension Methods

Name Description
ConfigureFromMethod(Command, MethodInfo, Object)
Invoke(Command, String, IConsole)
Invoke(Command, String[], IConsole)
InvokeAsync(Command, String, IConsole)
InvokeAsync(Command, String[], IConsole)
Parse(Command, String, IReadOnlyCollection<Char>)
Parse(Command, String[])
ToAsyncEnumerable<TSource>(IEnumerable<TSource>)

Converts an IEnumerable<T> to an IAsyncEnumerable<T>.

ToFrozenDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

Creates a FrozenDictionary<TKey,TValue> from an IEnumerable<T> according to specified key selector and element selector functions.

ToFrozenDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Creates a FrozenDictionary<TKey,TValue> from an IEnumerable<T> according to specified key selector function.

ToFrozenSet<T>(IEnumerable<T>, IEqualityComparer<T>)

Creates a FrozenSet<T> with the specified values.

ToImmutableArray<TSource>(IEnumerable<TSource>)

Creates an immutable array from the specified collection.

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers.

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>)

Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer.

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

Enumerates and transforms a sequence, and produces an immutable dictionary of its contents.

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Constructs an immutable dictionary based on some transformation of a sequence.

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys.

ToImmutableHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type.

ToImmutableHashSet<TSource>(IEnumerable<TSource>)

Enumerates a sequence and produces an immutable hash set of its contents.

ToImmutableList<TSource>(IEnumerable<TSource>)

Enumerates a sequence and produces an immutable list of its contents.

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>, IEqualityComparer<TValue>)

Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers.

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>)

Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer.

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents.

ToImmutableSortedSet<TSource>(IEnumerable<TSource>, IComparer<TSource>)

Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer.

ToImmutableSortedSet<TSource>(IEnumerable<TSource>)

Enumerates a sequence and produces an immutable sorted set of its contents.

UseCommandHandler<THandler>(Command)

Applies to