Spectre.Console.Cli Documentation

Build powerful command-line applications with Spectre.Console.Cli, a modern framework with a focus on type safety and developer experience.

Start Here

Get Spectre.Console.Cli running in seconds:

dotnet add package Spectre.Console.Cli

Then try this quick example that creates a simple greeting command:

public class GreetSettings : CommandSettings
{
    [CommandArgument(0, "<name>")]
    [Description("The name to greet")]
    public required string Name { get; init; }
  
    [CommandOption("-c|--count")]
    [Description("Number of times to greet")]
    [DefaultValue(1)]
    public int Count { get; init; }
}
  
public class GreetCommand : Command<GreetSettings>
{
    protected override int Execute(CommandContext context, GreetSettings settings, CancellationToken cancellation)
    {
        for (var i = 0; i < settings.Count; i++)
        {
            AnsiConsole.MarkupLine($"Hello, [green]{settings.Name}[/]!");
        }
        return 0;
    }
}

In your Program.cs, wire it up:

var app = new CommandApp<GreetCommand>();
return app.Run(args);

Run it with dotnet run -- World --count 3 to see typed argument parsing in action.

You should see something like this:

Screencast of Spectre.Console in action

Explore the Documentation

From simple single-command tools to complex CLI applications with nested commands and dependency injection, we've got you covered. The tutorials will walk you through the fundamentals, while the how-to guides tackle specific scenarios you'll encounter in real projects.

Tutorials

How-To Guides

Explanation

Reference