CommandManagerRunCommandAsync(ReadOnlyMemoryString) Method

Finds and instantiates the subcommand with the name from the first argument, and if it succeeds, runs it asynchronously. If it fails, writes error and usage information.

Definition

Namespace: Ookii.CommandLine.Commands
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public Task<int?> RunCommandAsync(
	ReadOnlyMemory<string> args
)

Parameters

args  ReadOnlyMemoryString
The command line arguments, where the first argument is the command name and the remaining ones are arguments for the command.

Return Value

TaskNullableInt32
A task representing the asynchronous run operation. The result is the value returned by IAsyncCommandRunAsync or ICommandRun, or if the command could not be created.

Remarks

This function creates the command by invoking the CreateCommand(ReadOnlyMemoryString) method. If the command implements the IAsyncCancelableCommand interface, it sets the IAsyncCancelableCommandCancellationToken property. If the command implements the IAsyncCommand interface, it invokes the IAsyncCommandRunAsync method; otherwise, it invokes the ICommandRun method on the command.

Commands that don't meet the criteria of the CommandOptionsCommandFilter predicate are not included.

If the CommandOptionsParentCommand property is , only commands without a ParentCommandAttribute attribute are included. If it is not , only commands where the type specified using the ParentCommandAttribute attribute matches the value of the property are included.

The automatic version command is included if the CommandOptionsAutoVersionCommand property is and the command name matches the name of the automatic version command, and not any other command name. The CommandOptionsCommandFilter and CommandOptionsParentCommand property also affect whether the version command is included.

See Also