CliRunAsyncTDefinition(String, CliSettings, CancellationToken) Method
Parses a command line string value and runs the handler asynchronously for the indicated command.
Namespace: DotMake.CommandLineAssembly: DotMake.CommandLine (in DotMake.CommandLine.dll) Version: 1.8.8
public static Task<int> RunAsync<TDefinition>(
string commandLine,
CliSettings settings = null,
CancellationToken cancellationToken = default
)
- commandLine String
-
The command line string that will be split into tokens as if it had been passed on the command line. Useful for testing command line input by just specifying it as a single string.
- settings CliSettings (Optional)
-
The settings for the parser's grammar and behaviors.
- cancellationToken CancellationToken (Optional)
-
The token to monitor for cancellation requests.
- TDefinition
-
The definition class for the command. A command builder for this class should be automatically generated by the source generator.
TaskInt32
The exit code for the invocation.
//In Program.cs, to go async, add this single line:
await Cli.RunAsync<RootCliCommand>("NewValueForArgument1 --option-1 NewValueForOption1");
//In Program.cs, to go async, add this single line for returning exit code:
return await Cli.RunAsync<RootCliCommand>("NewValueForArgument1 --option-1 NewValueForOption1");