Repl.Spectre
0.11.0-dev.6
dotnet add package Repl.Spectre --version 0.11.0-dev.6
NuGet\Install-Package Repl.Spectre -Version 0.11.0-dev.6
<PackageReference Include="Repl.Spectre" Version="0.11.0-dev.6" />
<PackageVersion Include="Repl.Spectre" Version="0.11.0-dev.6" />
<PackageReference Include="Repl.Spectre" />
paket add Repl.Spectre --version 0.11.0-dev.6
#r "nuget: Repl.Spectre, 0.11.0-dev.6"
#:package Repl.Spectre@0.11.0-dev.6
#addin nuget:?package=Repl.Spectre&version=0.11.0-dev.6&prerelease
#tool nuget:?package=Repl.Spectre&version=0.11.0-dev.6&prerelease
Repl.Spectre
Spectre.Console integration for Repl Toolkit. Provides rich interactive prompts, injectable IAnsiConsole, a lightweight Spectre output format, and an interaction presenter that can capture feedback during screen-owned flows.
Features
- Rich prompts —
SelectionPrompt,MultiSelectionPrompt,ConfirmationPrompt,TextPrompt, and secret input via Spectre.Console - IAnsiConsole injection — use
IAnsiConsoleas a command parameter to render tables, trees, panels, and other Spectre renderables - Lightweight output — the
"spectre"output format renders objects, results, help, and collections with less chrome than the default Spectre widgets - Banner support — inject
IAnsiConsoleintoWithBanner()callbacks for rich startup banners (FigletText, Markup, etc.) - Capture support —
SpectreInteractionPresenter.BeginCapture(...)redirects REPL feedback away from a screen-owned Spectre surface - Configurable capabilities —
SpectreConsoleOptionsto control Unicode rendering for different terminal environments
Setup
var app = ReplApp.Create(services =>
{
services.AddSpectreConsole(); // DI: IAnsiConsole + SpectreInteractionHandler + SpectreInteractionPresenter
})
.UseSpectreConsole(); // Output transformer + banner format + UTF-8 encoding
Two calls, two concerns:
| Method | Scope | What it does |
|---|---|---|
AddSpectreConsole() |
IServiceCollection |
Registers IAnsiConsole, SpectreInteractionHandler, and SpectreInteractionPresenter in DI |
UseSpectreConsole() |
ReplApp |
Registers "spectre" output transformer, sets it as default, adds --spectre, enables banners, configures UTF-8 |
Usage
Auto-rendered tables
Return a collection from a command — the output transformer renders it as a lightweight Spectre table:
app.Map("list", (IContactStore store) => store.All());
Column headers are derived from [Display] attributes. No rendering code needed.
Direct IAnsiConsole injection
Inject IAnsiConsole to use any Spectre renderable:
app.Map("report", (IAnsiConsole console) =>
{
var table = new Table().AddColumn("Name").AddColumn("Value");
table.AddRow("Item", "42");
console.Write(table);
});
Works with all Spectre renderables: Table, Tree, Panel, BarChart, Calendar, FigletText, Progress, Status, and more.
Format switching
UseSpectreConsole() makes spectre the default output format. You can still switch per-command:
--spectreselects the Spectre renderer--humanswitches back to the standard text renderer--output:<format>remains the canonical selector
--help respects the selected format as well, so --spectre --help uses Spectre help while --human --help returns the classic text help.
Transparent prompt upgrade
IReplInteractionChannel calls are automatically rendered as Spectre prompts:
| Channel method | Spectre prompt |
|---|---|
AskTextAsync |
TextPrompt<string> |
AskChoiceAsync |
SelectionPrompt<string> |
AskMultiChoiceAsync |
MultiSelectionPrompt<string> |
AskConfirmationAsync |
ConfirmationPrompt |
AskSecretAsync |
TextPrompt<string>.Secret() |
No Spectre-specific code in handlers — the same handler works with or without the Spectre package.
Capture feedback during screen-owned flows
If your command temporarily owns the terminal surface, do not mix that full-screen/live Spectre rendering with regular REPL status/progress output on the same writer. Instead, capture interaction feedback explicitly:
app.Map("dashboard", static async (
SpectreInteractionPresenter presenter,
IReplIoContext io,
CancellationToken ct) =>
{
using var capture = presenter.BeginCapture(io.Error);
await RunDashboardAsync(ct);
});
The TextWriter overload emits plain text only. In application handlers, prefer a session-aware sink such as IReplIoContext.Error. Reserve raw writers for host/tooling code that already owns the transport surface.
You can also capture to a custom presenter:
using var capture = presenter.BeginCapture(myPresenter);
This is the intended integration point for future TUI tooling.
Banner with IAnsiConsole
Use IAnsiConsole in banner callbacks for rich startup output:
app.WithBanner((IAnsiConsole console) =>
{
console.Write(new FigletText("My App").Color(Color.Blue));
console.MarkupLine("[grey]Type 'help' to get started[/]");
});
Configuration
UseSpectreConsole() accepts an optional callback to configure capabilities:
// Default: Unicode enabled
.UseSpectreConsole()
// Disable Unicode for limited terminals
.UseSpectreConsole(o => o.Unicode = false)
SpectreConsoleOptions
| Property | Type | Default | Description |
|---|---|---|---|
Unicode |
bool |
true |
Enable Unicode box-drawing characters and symbols. When false, Spectre falls back to ASCII. |
When Unicode is enabled, UseSpectreConsole() sets Console.OutputEncoding to UTF-8 to ensure
Unicode characters (progress bars, spinners, box-drawing) render correctly on Windows.
Docs
- Cookbook: Spectre.Console — setup, prompts, renderables, capture, banners
- Interactivity — IReplInteractionChannel, prompt contracts, progress
- Best Practices — static lambdas, test patterns, DI composition
Sample
See sample 07-spectre for a comprehensive demo covering 21 Spectre features across 14 commands.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Repl.Defaults (>= 0.11.0-dev.6)
- Spectre.Console (>= 0.55.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.11.0-dev.6 | 316 | 5/2/2026 |
| 0.11.0-dev.4 | 42 | 5/1/2026 |
| 0.11.0-dev.3 | 45 | 4/25/2026 |
| 0.10.0 | 934 | 4/25/2026 |
| 0.10.0-dev.83 | 55 | 4/25/2026 |
| 0.10.0-dev.77 | 988 | 4/20/2026 |
| 0.10.0-dev.76 | 78 | 4/19/2026 |
| 0.10.0-dev.59 | 46 | 4/13/2026 |
| 0.10.0-dev.58 | 3,128 | 4/7/2026 |
| 0.10.0-dev.52 | 47 | 4/7/2026 |
| 0.10.0-dev.39 | 51 | 4/4/2026 |
| 0.10.0-dev.36 | 58 | 4/4/2026 |
| 0.10.0-dev.35 | 47 | 4/4/2026 |
| 0.10.0-dev.31 | 47 | 4/3/2026 |
| 0.10.0-dev.20 | 68 | 3/30/2026 |
| 0.10.0-dev.19 | 57 | 3/29/2026 |
| 0.10.0-dev.17 | 53 | 3/29/2026 |
| 0.10.0-dev.14 | 52 | 3/29/2026 |
| 0.10.0-dev.2 | 48 | 3/25/2026 |
| 0.9.2 | 92 | 3/25/2026 |