Class AppBuilder
- Namespace
- Ploch.CommandLine.Spectre
- Assembly
- Ploch.CommandLine.Spectre.dll
Provides a builder for configuring and constructing a command-line application.
public class AppBuilder : IDisposable
- Inheritance
-
AppBuilder
- Implements
- Inherited Members
- Extension Methods
Remarks
The AppBuilder class allows for the creation and customisation of a command-line application by specifying its name, description, version, and other configurations. It integrates with the Spectre.Console.Cli library for command-line interface functionality and Microsoft.Extensions.Hosting for dependency injection and configuration. The host it configures is built for those purposes once a run reaches command resolution, and the library never starts it; see ConfigureCommandApp(Action<IConfigurator>).
Constructors
- AppBuilder(ConsoleAppInfo, CancellationTokenSource)
Initializes a new instance of the AppBuilder class around a caller-supplied cancellation source.
Methods
- AddServicesBundle<TServicesBundle>()
Registers a services bundle to be configured when the application is built.
- ConfigureAppConfiguration(Action<IConfigurationBuilder>)
Configures the application's configuration using the specified delegate.
- ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder>)
Configures the application's configuration using the specified delegate.
- ConfigureCommandApp(Action<IConfigurator>)
Builds and configures the command-line application.
- ConfigureHost(Action<IHostBuilder>)
Configures the host builder for the application.
- ConfigureServices(Action<IServiceCollection>)
Configures the services for the application.
- ConfigureServices(Action<HostBuilderContext, IServiceCollection>)
Configures the services for the application using the specified configurator.
- Create(params IEnumerable<string>)
Creates a new instance of the AppBuilder class with the specified arguments.
- Dispose()
Releases the cancellation source and the
Console.CancelKeyPresshandler this builder owns.
- Dispose(bool)
Releases the resources this builder owns.
- ShowBanner(bool)
Sets whether the library writes its own lines to standard error: the start-up banner — the name as FigletText, the name and version line and the description — when ConfigureCommandApp(Action<IConfigurator>) builds the application, and the "Executing command" line before each command. Both are written unless this is called with false.
- WithDescription(string)
Sets the description of the application.
- WithName(string)
Sets the name of the application.
- WithVersion(Version)
Sets the version of the application.