CommandExtensions.InvokeAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
InvokeAsync(Command, String, IConsole) |
Parses and invokes a command. |
InvokeAsync(Command, String[], IConsole) |
Parses and invokes a command. |
InvokeAsync(Command, String, IConsole)
Parses and invokes a command.
public static System.Threading.Tasks.Task<int> InvokeAsync (this System.CommandLine.Command command, string commandLine, System.CommandLine.IConsole? console = default);
static member InvokeAsync : System.CommandLine.Command * string * System.CommandLine.IConsole -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function InvokeAsync (command As Command, commandLine As String, Optional console As IConsole = Nothing) As Task(Of Integer)
Parameters
- command
- Command
The command to invoke.
- commandLine
- String
The command line to parse.
- console
- IConsole
The console to which output is written during invocation.
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(Command, String, IConsole).
Applies to
InvokeAsync(Command, String[], IConsole)
Parses and invokes a command.
public static System.Threading.Tasks.Task<int> InvokeAsync (this System.CommandLine.Command command, string[] args, System.CommandLine.IConsole? console = default);
static member InvokeAsync : System.CommandLine.Command * string[] * System.CommandLine.IConsole -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function InvokeAsync (command As Command, args As String(), Optional console As IConsole = Nothing) As Task(Of Integer)
Parameters
- command
- Command
The command to invoke.
- args
- String[]
The arguments to parse.
- console
- IConsole
The console to which output is written during invocation.
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(Command, String[], IConsole).