Class HostBuilderExtensions
Extension methods for Microsoft.Extensions.Hosting.IHostBuilder support.
Inheritance
System.Object
HostBuilderExtensions
Namespace: Microsoft.Extensions.Hosting
Assembly: McMaster.Extensions.Hosting.CommandLine.dll
Syntax
public static class HostBuilderExtensions
Methods
| Improve this Doc View SourceRunCommandLineApplicationAsync(IHostBuilder, String[], Action<CommandLineApplication>, CancellationToken)
Runs an instance of CommandLineApplication using builder API to provide
command line parsing on the given args
.
Declaration
public static Task<int> RunCommandLineApplicationAsync(this IHostBuilder hostBuilder, string[] args, Action<CommandLineApplication> configure, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Hosting.IHostBuilder | hostBuilder | This instance |
System.String[] | args | The command line arguments |
System.Action<CommandLineApplication> | configure | The delegate to configure the application |
System.Threading.CancellationToken | cancellationToken | A cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | A task whose result is the exit code of the application |
RunCommandLineApplicationAsync<TApp>(IHostBuilder, String[], CancellationToken)
Runs an instance of TApp
using CommandLineApplication to provide
command line parsing on the given args
. This method should be the primary approach
taken for command line applications.
Declaration
public static Task<int> RunCommandLineApplicationAsync<TApp>(this IHostBuilder hostBuilder, string[] args, CancellationToken cancellationToken = default(CancellationToken))
where TApp : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Hosting.IHostBuilder | hostBuilder | This instance |
System.String[] | args | The command line arguments |
System.Threading.CancellationToken | cancellationToken | A cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | A task whose result is the exit code of the application |
Type Parameters
Name | Description |
---|---|
TApp | The type of the command line application implementation |