XO.Console.Cli.Extensions
5.0.9
dotnet add package XO.Console.Cli.Extensions --version 5.0.9
NuGet\Install-Package XO.Console.Cli.Extensions -Version 5.0.9
<PackageReference Include="XO.Console.Cli.Extensions" Version="5.0.9" />
paket add XO.Console.Cli.Extensions --version 5.0.9
#r "nuget: XO.Console.Cli.Extensions, 5.0.9"
// Install XO.Console.Cli.Extensions as a Cake Addin #addin nuget:?package=XO.Console.Cli.Extensions&version=5.0.9 // Install XO.Console.Cli.Extensions as a Cake Tool #tool nuget:?package=XO.Console.Cli.Extensions&version=5.0.9
XO.Console.Cli.Extensions
This library integrates XO.Console.Cli applications with the .NET runtime extensions, including dependency injection and the .NET Generic Host. By default, the integration:
- Adds
CommandAppBuilderOptions
andICommandApp
to the service collection - Configures XO.Console.Cli to create instances of command and parameters types using
IServiceProvider
(which means you can use constructor injection for dependencies) - Sets the command-line application name to
IHostEnvironment.ApplicationName
- Wraps
IHost
startup and command execution to ensure the application reliably logs critical exceptions and responds to shutdown signals
Getting Started
1. Add a reference
> dotnet add package XO.Console.Cli.Extensions
If your project does not already reference Microsoft.Extensions.Hosting, add that, too.
> dotnet add package Microsoft.Extensions.Hosting
2. Set up and run the host
return await Host.CreateDefaultBuilder(args)
.RunCommandAppAsync(args, static (context, builder) => {
builder.AddCommand<GreetingCommand>("greet");
});
Integration with the simpler IHostApplicationBuilder
is also possible. First, add the command-line application to the service collection. Then, build the host. Finally, run the configured command-line application.
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Services.AddCommandApp(static (context, builder) => {
builder.AddCommand<GreetingCommand>("greet");
});
IHost host = builder.Build();
return await host.RunCommandAppAsync(args);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- XO.Console.Cli (>= 5.0.42)
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- XO.Console.Cli (>= 5.0.42)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XO.Console.Cli.Extensions:
Package | Downloads |
---|---|
XO.Console.Cli.Instrumentation
OpenTelemetry instrumentation for XO.Console.Cli |
GitHub repositories
This package is not used by any popular GitHub repositories.