CliRunAsyncTDefinition(String, CliSettings, CancellationToken) Method

Parses a command line string value and runs the handler asynchronously for the indicated command.

Definition

Namespace: DotMake.CommandLine
Assembly: DotMake.CommandLine (in DotMake.CommandLine.dll) Version: 2.6.8
C#
public static Task<int> RunAsync<TDefinition>(
	string commandLine,
	CliSettings settings = null,
	CancellationToken cancellationToken = default
)

Parameters

commandLine  String

[Missing <param name="commandLine"/> documentation for "M:DotMake.CommandLine.Cli.RunAsync``1(System.String,DotMake.CommandLine.CliSettings,System.Threading.CancellationToken)"]

settings  CliSettings  (Optional)
The settings for the parser's grammar and behaviors.
cancellationToken  CancellationToken  (Optional)

[Missing <param name="cancellationToken"/> documentation for "M:DotMake.CommandLine.Cli.RunAsync``1(System.String,DotMake.CommandLine.CliSettings,System.Threading.CancellationToken)"]

Type Parameters

TDefinition
The definition class for the command. A command builder for this class should be automatically generated by the source generator.

Return Value

TaskInt32
The exit code for the invocation.

Example

C#
//In Program.cs, to go async, add this single line:
await Cli.RunAsync<RootCliCommand>("NewValueForArgument1 --option-1 NewValueForOption1");
C#
//In Program.cs, to go async, add this single line for returning exit code:
return await Cli.RunAsync<RootCliCommand>("NewValueForArgument1 --option-1 NewValueForOption1");

See Also