Edit

Share via


ParserExtensions.InvokeAsync Method

Definition

Overloads

InvokeAsync(Parser, String, IConsole)

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

InvokeAsync(Parser, String[], IConsole)

Parses a command line string array and invokes the handler for the indicated command.

InvokeAsync(Parser, String, IConsole)

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

public static System.Threading.Tasks.Task<int> InvokeAsync (this System.CommandLine.Parsing.Parser parser, string commandLine, System.CommandLine.IConsole? console = default);
static member InvokeAsync : System.CommandLine.Parsing.Parser * string * System.CommandLine.IConsole -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function InvokeAsync (parser As Parser, commandLine As String, Optional console As IConsole = Nothing) As Task(Of Integer)

Parameters

parser
Parser
commandLine
String
console
IConsole

Returns

The exit code for the invocation.

Remarks

The command line string input will be split into tokens as if it had been passed on the command line.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Invoke(Parser, String, IConsole).

Applies to

InvokeAsync(Parser, String[], IConsole)

Parses a command line string array and invokes the handler for the indicated command.

public static System.Threading.Tasks.Task<int> InvokeAsync (this System.CommandLine.Parsing.Parser parser, string[] args, System.CommandLine.IConsole? console = default);
static member InvokeAsync : System.CommandLine.Parsing.Parser * string[] * System.CommandLine.IConsole -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function InvokeAsync (parser As Parser, args As String(), Optional console As IConsole = Nothing) As Task(Of Integer)

Parameters

parser
Parser
args
String[]
console
IConsole

Returns

The exit code for the invocation.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Invoke(Parser, String[], IConsole).

Applies to