Skip to content

albx/Spectre.Console.Extensions

Repository files navigation

Spectre.Console Extensions

This project contains some extensions for the Spectre.Console CLI project. It adds a CommandAppBuilder which enables features like Dependency injection.

Installation

This project is available on NuGet.

It can be installed using the dotnet add package command or the NuGet wizard on your favourite IDE.

  dotnet add package SpectreConsole.Extensions

Usage

In your Program.cs you can create a CommandAppBuilder class and then register your services:

using Spectre.Console.Extensions;

var builder = CommandAppBuilder.Create();

//Register your services with the Services property. i.e.
builder.Services.AddSingleton(....);

//Create the CommandApp instance
var app = builder.Build();
app.Configure(config => { /* your app configuration */ });

//Create the CommandApp instance with its default command
var app = builder.Build<DefaultCommand>();
app.Configure(config => { /* your app configuration */ });

return app.Run(args);

It's possibile to specify the app configration in the overloads of the Build and Build<TDefaultCommandMethod>:

// ...

//Create the CommandApp instance
var app = builder.Build(config => { /* your app configuration */ });

//Create the CommandApp instance with its default command
var app = builder.Build<DefaultCommand>(config => { /* your app configuration */ });

// ...

Samples

Samples are located in the samples folder.

Contributing

Contributions are always welcome!

If you want to submit any issues or new features, please follow these few guidelines.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages