Class HostBuilderExtensions
- Namespace
- Microsoft.Extensions.Hosting
- Assembly
- McMaster.Extensions.Hosting.CommandLine.dll
Extension methods for IHostBuilder support.
public static class HostBuilderExtensions
- Inheritance
-
objectHostBuilderExtensions
Methods
RunCommandLineApplicationAsync(IHostBuilder, string[], Action<CommandLineApplication>, CancellationToken)
Runs an instance of CommandLineApplication using builder API to provide
command line parsing on the given args.
public static Task<int> RunCommandLineApplicationAsync(this IHostBuilder hostBuilder, string[] args, Action<CommandLineApplication> configure, CancellationToken cancellationToken = default)
Parameters
hostBuilderIHostBuilderThis instance
argsstring[]The command line arguments
configureAction<CommandLineApplication>The delegate to configure the application
cancellationTokenCancellationTokenA cancellation token
Returns
RunCommandLineApplicationAsync<TApp>(IHostBuilder, string[], Action<CommandLineApplication<TApp>>, 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.
public static Task<int> RunCommandLineApplicationAsync<TApp>(this IHostBuilder hostBuilder, string[] args, Action<CommandLineApplication<TApp>> configure, CancellationToken cancellationToken = default) where TApp : class
Parameters
hostBuilderIHostBuilderThis instance
argsstring[]The command line arguments
configureAction<CommandLineApplication<TApp>>The delegate to configure the application
cancellationTokenCancellationTokenA cancellation token
Returns
Type Parameters
TAppThe type of the command line application implementation
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.
public static Task<int> RunCommandLineApplicationAsync<TApp>(this IHostBuilder hostBuilder, string[] args, CancellationToken cancellationToken = default) where TApp : class
Parameters
hostBuilderIHostBuilderThis instance
argsstring[]The command line arguments
cancellationTokenCancellationTokenA cancellation token
Returns
Type Parameters
TAppThe type of the command line application implementation
UseCommandLineApplication<TApp>(IHostBuilder, string[])
Configures an instance of TApp using CommandLineApplication to provide
command line parsing on the given args.
public static IHostBuilder UseCommandLineApplication<TApp>(this IHostBuilder hostBuilder, string[] args) where TApp : class
Parameters
hostBuilderIHostBuilderThis instance
argsstring[]The command line arguments
Returns
Type Parameters
TAppThe type of the command line application implementation
UseCommandLineApplication<TApp>(IHostBuilder, string[], Action<CommandLineApplication<TApp>>)
Configures an instance of TApp using CommandLineApplication to provide
command line parsing on the given args.
public static IHostBuilder UseCommandLineApplication<TApp>(this IHostBuilder hostBuilder, string[] args, Action<CommandLineApplication<TApp>> configure) where TApp : class
Parameters
hostBuilderIHostBuilderThis instance
argsstring[]The command line arguments
configureAction<CommandLineApplication<TApp>>The delegate to configure the application
Returns
Type Parameters
TAppThe type of the command line application implementation