Redigera

Dela via


Command Class

Definition

Represents a specific action that the application performs.

public ref class Command : System::CommandLine::IdentifierSymbol, System::Collections::Generic::IEnumerable<System::CommandLine::Symbol ^>
public class Command : System.CommandLine.IdentifierSymbol, System.Collections.Generic.IEnumerable<System.CommandLine.Symbol>
type Command = class
    inherit IdentifierSymbol
    interface seq<Symbol>
    interface IEnumerable
Public Class Command
Inherits IdentifierSymbol
Implements IEnumerable(Of Symbol)
Inheritance
Derived
Implements

Remarks

Use the Command object for actions that correspond to a specific string (the command name). See RootCommand for simple applications that only have one action. For example, dotnet run uses run as the command.

Constructors

Command(String, String)

Initializes a new instance of the Command class.

Properties

Aliases

Gets the set of strings that can be used on the command line to specify the symbol.

(Inherited from IdentifierSymbol)
Arguments

Represents all of the arguments for the command.

Children

Gets the child symbols.

Description

Gets or sets the description of the symbol.

(Inherited from Symbol)
Handler

Gets or sets the ICommandHandler for the command. The handler represents the action that will be performed when the command is invoked.

IsHidden

Gets or sets a value indicating whether the symbol is hidden.

(Inherited from Symbol)
Name

Gets or sets the symbol name.

(Inherited from IdentifierSymbol)
Options

Represents all of the options for the command, including global options that have been applied to any of the command's ancestors.

Parents

Gets the parent symbols.

(Inherited from Symbol)
Subcommands

Represents all of the subcommands for the command.

TreatUnmatchedTokensAsErrors

Gets or sets a value that indicates whether unmatched tokens should be treated as errors. For example, if set to true and an extra command or argument is provided, validation will fail.

Methods

Add(Argument)

Adds an Argument to the command.

Add(Command)

Adds a subcommand to the command.

Add(Option)

Adds an Option to the command.

AddAlias(String)

Adds an alias.

(Inherited from IdentifierSymbol)
AddArgument(Argument)

Adds an Argument to the command.

AddCommand(Command)

Adds a subcommand to the command.

AddGlobalOption(Option)

Adds a global Option to the command.

AddOption(Option)

Adds an Option to the command.

AddValidator(ValidateSymbolResult<CommandResult>)

Adds a custom validator to the command. Validators can be used to create custom validation logic.

GetCompletions()

Gets completions for the symbol.

(Inherited from Symbol)
GetCompletions(CompletionContext)

Gets the suggested values for command line completion.

GetEnumerator()

Gets an enumerator that represents all of the symbols for the command.

HasAlias(String)

Determines whether the alias has already been defined.

(Inherited from IdentifierSymbol)
ToString()

Returns a string that represents the current object.

(Inherited from Symbol)

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

Extension Methods

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.

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.

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>(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.

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.

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.

Invoke(Command, String, IConsole)

Parses and invokes a command.

Invoke(Command, String[], IConsole)

Parses and invokes a command.

InvokeAsync(Command, String, IConsole)

Parses and invokes a command.

InvokeAsync(Command, String[], IConsole)

Parses and invokes a command.

Parse(Command, String)

Parses a command line string value using the specified command.

Parse(Command, String[])

Parses an array strings using the specified command.

ConfigureFromMethod(Command, MethodInfo, Object)
SetHandler(Command, Action)

Sets a command's handler based on an Action.

SetHandler(Command, Action<InvocationContext>)
SetHandler(Command, Func<InvocationContext,Task>)
SetHandler(Command, Func<Task>)

Sets a command's handler based on a Func<TResult>.

SetHandler<T>(Command, Action<T>, IValueDescriptor[])

Sets a command's handler based on an Action<T>.

SetHandler<T>(Command, Action<T>, IValueDescriptor<T>)
SetHandler<T>(Command, Func<T,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T,TResult>.

SetHandler<T>(Command, Func<T,Task>, IValueDescriptor<T>)
SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15, T16>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13, T14,T15,T16>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15, T16>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13, T14,T15,T16,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult>.

SetHandler<T1,T2>(Command, Action<T1,T2>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2>.

SetHandler<T1,T2>(Command, Action<T1,T2>, IValueDescriptor<T1>, IValueDescriptor<T2>)
SetHandler<T1,T2>(Command, Func<T1,T2,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,TResult>.

SetHandler<T1,T2>(Command, Func<T1,T2,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>)
SetHandler<T1,T2,T3>(Command, Action<T1,T2,T3>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3>.

SetHandler<T1,T2,T3>(Command, Action<T1,T2,T3>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>)
SetHandler<T1,T2,T3>(Command, Func<T1,T2,T3,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,TResult>.

SetHandler<T1,T2,T3>(Command, Func<T1,T2,T3,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>)
SetHandler<T1,T2,T3,T4>(Command, Action<T1,T2,T3,T4>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4>.

SetHandler<T1,T2,T3,T4>(Command, Action<T1,T2,T3,T4>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>)
SetHandler<T1,T2,T3,T4>(Command, Func<T1,T2,T3,T4,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,TResult>.

SetHandler<T1,T2,T3,T4>(Command, Func<T1,T2,T3,T4,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>)
SetHandler<T1,T2,T3,T4,T5>(Command, Action<T1,T2,T3,T4,T5>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5>.

SetHandler<T1,T2,T3,T4,T5>(Command, Action<T1,T2,T3,T4,T5>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>)
SetHandler<T1,T2,T3,T4,T5>(Command, Func<T1,T2,T3,T4,T5,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,TResult>.

SetHandler<T1,T2,T3,T4,T5>(Command, Func<T1,T2,T3,T4,T5,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>)
SetHandler<T1,T2,T3,T4,T5,T6>(Command, Action<T1,T2,T3,T4,T5,T6>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6>.

SetHandler<T1,T2,T3,T4,T5,T6>(Command, Action<T1,T2,T3,T4,T5, T6>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>)
SetHandler<T1,T2,T3,T4,T5,T6>(Command, Func<T1,T2,T3,T4,T5,T6,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6>(Command, Func<T1,T2,T3,T4,T5,T6, Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>)
SetHandler<T1,T2,T3,T4,T5,T6,T7>(Command, Action<T1,T2,T3,T4,T5,T6,T7>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7>.

SetHandler<T1,T2,T3,T4,T5,T6,T7>(Command, Action<T1,T2,T3,T4, T5,T6,T7>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>, IValueDescriptor<T7>)
SetHandler<T1,T2,T3,T4,T5,T6,T7>(Command, Func<T1,T2,T3,T4,T5,T6,T7,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7>(Command, Func<T1,T2,T3,T4,T5, T6,T7,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>, IValueDescriptor<T7>)
SetHandler<T1,T2,T3,T4,T5,T6,T7,T8>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8>(Command, Action<T1,T2,T3, T4,T5,T6,T7,T8>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>, IValueDescriptor<T7>, IValueDescriptor<T8>)
SetHandler<T1,T2,T3,T4,T5,T6,T7,T8>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,TResult>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8>(Command, Func<T1,T2,T3,T4, T5,T6,T7,T8,Task>, IValueDescriptor<T1>, IValueDescriptor<T2>, IValueDescriptor<T3>, IValueDescriptor<T4>, IValueDescriptor<T5>, IValueDescriptor<T6>, IValueDescriptor<T7>, IValueDescriptor<T8>)
SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9>(Command, Action<T1,T2,T3,T4,T5,T6,T7,T8,T9>, IValueDescriptor[])

Sets a command's handler based on an Action<T1,T2,T3,T4,T5,T6,T7,T8,T9>.

SetHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9>(Command, Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,Task>, IValueDescriptor[])

Sets a command's handler based on a Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

ToAsyncEnumerable<TSource>(IEnumerable<TSource>)

Creates a new IAsyncEnumerable<T> that iterates through source.

Applies to