Language

RootCommand Class

Definition

Represents the main action that the application performs.

public ref class RootCommand : System::CommandLine::Command
public class RootCommand : System.CommandLine.Command
type RootCommand = class
    inherit Command
Public Class RootCommand
Inherits Command
Inheritance
RootCommand

Remarks

Use the RootCommand object without any subcommands for applications that perform one action. Add subcommands to the root for applications that require actions identified by specific strings. For example, `dir` does not use any subcommands. See Command for applications with multiple actions.

Constructors

Name Description
RootCommand(String)

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.

(Inherited from Command)
Aliases

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

(Inherited from Command)
Argument
Obsolete.
(Inherited from Command)
Arguments

Gets all of the arguments for the command.

(Inherited from Command)
Children

Gets the child symbols.

(Inherited from Command)
Description

Gets or sets the description of the symbol.

(Inherited from Symbol)
Directives

Represents all of the directives that are valid under the root command.

ExecutableName

The name of the currently running executable.

ExecutablePath

The path to the currently running executable.

ExeName
ExePath
Handler (Inherited from Command)
HelpName

Gets or sets the name used for the root command in help output.

Hidden

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

(Inherited from Symbol)
IsHidden (Inherited from Symbol)
Name
Name

Gets the name of the symbol.

(Inherited from Symbol)
Options

Gets all of the options for the command.

(Inherited from Command)
Parents

Gets the parent symbols.

(Inherited from Symbol)
RawAliases (Inherited from Symbol)
Subcommands

Gets all of the subcommands for the command.

(Inherited from Command)
TreatUnmatchedTokensAsErrors

Gets or sets a value that indicates whether unmatched tokens should be treated as errors.

(Inherited from Command)
Validators

Gets the validators to the command. Validators can be used to create custom validation logic.

(Inherited from Command)

Methods

Name Description
Add(Argument)

Adds a Argument to the command.

(Inherited from Command)
Add(Command)

Adds a Command to the command.

(Inherited from Command)
Add(Directive)

Adds a Directive to the command.

Add(Option)

Adds an Option to the command.

(Inherited from Command)
Add(Symbol) (Inherited from Command)
AddAlias(String) (Inherited from Command)
AddAliasInner(String) (Inherited from Symbol)
AddArgument(Argument) (Inherited from Command)
AddCommand(Command) (Inherited from Command)
AddOption(Option) (Inherited from Command)
AddValidator(ValidateSymbol<CommandResult>) (Inherited from Command)
ClearAliases() (Inherited from Symbol)
GetCompletions(CompletionContext)

Gets completions for the symbol.

(Inherited from Command)
GetEnumerator() (Inherited from Command)
HasAlias(String) (Inherited from Symbol)
HasRawAlias(String) (Inherited from Symbol)
Parse(IReadOnlyList<String>, ParserConfiguration)

Parses an array strings using the command.

(Inherited from Command)
Parse(String, ParserConfiguration)

Parses a command line string value using the command.

(Inherited from Command)
SetAction(Action<ParseResult>)

Sets a synchronous action to be run when the command is invoked.

(Inherited from Command)
SetAction(Func<ParseResult,CancellationToken,Task<Int32>>)

Sets an asynchronous action when the command is invoked.

(Inherited from Command)
SetAction(Func<ParseResult,CancellationToken,Task>)

Sets an asynchronous action to be run when the command is invoked.

(Inherited from Command)
SetAction(Func<ParseResult,Int32>)

Sets a synchronous action to be run when the command is invoked.

(Inherited from Command)
SetAction(Func<ParseResult,Task<Int32>>)

Sets an asynchronous action to be run when the command is invoked.

(Inherited from Command)
SetAction(Func<ParseResult,Task>)

Sets an asynchronous action to be run when the command is invoked.

(Inherited from Command)
Suggest(String) (Inherited from Symbol)
ToString()

Returns a string that represents the current object.

(Inherited from Symbol)

Explicit Interface Implementations

Name Description
ICommand.Argument (Inherited from Command)
ICommand.Arguments (Inherited from Command)
ICommand.Options (Inherited from Command)
IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

(Inherited from Command)
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