public static Task<int> RunAsync(
Delegate cliCommandAsDelegate,
CliSettings settings = null,
CancellationToken cancellationToken = default
)
([CliArgument] string argument1, bool option1) => { }
([CliArgument] string argument1, bool option1) => { return 0; }
async ([CliArgument] string argument1, bool option1) => { await Task.Delay(1000); }
MethodReference
[Missing <param name="cancellationToken"/> documentation for "M:DotMake.CommandLine.Cli.RunAsync(System.Delegate,DotMake.CommandLine.CliSettings,System.Threading.CancellationToken)"]
//In Program.cs, to go async, add this simple code:
Cli.Run(async ([CliArgument] string argument1, bool option1) =>
{
Console.WriteLine($@"Value for {nameof(argument1)} parameter is '{argument1}'");
Console.WriteLine($@"Value for {nameof(option1)} parameter is '{option1}'");
await Task.Delay(1000);
});
//Or:
Cli.Run(Method);
async Task Method([CliArgument] string argument2, bool option2)
{
Console.WriteLine($@"Value for {nameof(argument2)} parameter is '{argument2}'");
Console.WriteLine($@"Value for {nameof(option2)} parameter is '{option2}'");
await Task.Delay(1000);
}
//In Program.cs, to go async, add this simple code for returning exit code:
return Cli.Run(async ([CliArgument] string argument1, bool option1) =>
{
Console.WriteLine($@"Value for {nameof(argument1)} parameter is '{argument1}'");
Console.WriteLine($@"Value for {nameof(option1)} parameter is '{option1}'");
await Task.Delay(1000);
return 0;
});