Customization & Output
Repl’s output pipeline is fully composable. The same command graph produces plain text for a CI log, syntax-highlighted JSON for a terminal, and Spectre.Console tables for a rich interactive session — all without touching handler code.
Output formats
Section titled “Output formats”Every command supports output format flags out of the box:
| Flag | Format |
|---|---|
| (none) | human — plain text / table |
--output:format=json (or --json) | JSON |
--output:format=xml | XML |
--output:format=yaml | YAML |
--output:format=markdown | Markdown table |
--output:format=spectre | Spectre.Console rendering |
Format selection order
Section titled “Format selection order”--output:formatflag on the command lineReplOptions.Output.DefaultFormat(configured at startup)human(built-in default)
Set the default format
Section titled “Set the default format”app.Options(o =>{ o.Output.DefaultFormat = "json"; // all commands default to JSON});ANSI capability levels
Section titled “ANSI capability levels”Repl detects the terminal’s color capability at startup and chooses rendering accordingly.
Repl detects the terminal’s color capability at startup and chooses rendering accordingly. Detected capability tiers (informational):
| Detected tier | Rendering |
|---|---|
| No ANSI | Plain text, no escape sequences |
| Basic | 16 ANSI colors |
| Extended | 256 colors |
| TrueColor | 24-bit color |
Detection chain (first match wins):
NO_COLORenv var → disable ANSICLICOLOR_FORCEenv var → force ANSITERM/COLORTERMheuristics- Platform-specific checks (Windows Console, VS Code terminal, etc.)
- Redirection check (piped stdout → no ANSI)
Override programmatically using AnsiMode:
app.Options(o =>{ o.Output.AnsiMode = AnsiMode.Always; // force ANSI on regardless of detection // or: Auto (default — let detection decide), Never (force off)});JSON colorization
Section titled “JSON colorization”In interactive mode with ANSI support, --json output is automatically syntax-highlighted (keys in one color, strings in another, numbers in a third). No configuration required.
Render width
Section titled “Render width”Repl uses the terminal width for table column sizing, word wrap, and layout decisions.
Resolution order:
OutputOptions.PreferredWidth(explicit override)COLUMNSenvironment variable- Detected console window width
- Telnet NAWS / DTTERM resize for hosted sessions
OutputOptions.FallbackWidth(default:120)
app.Configure<OutputOptions>(o =>{ o.PreferredWidth = 160; o.FallbackWidth = 80;});Custom output transformers
Section titled “Custom output transformers”Register a transformer for a new format name:
app.Options(o =>{ o.Output.AddTransformer("csv", new CsvOutputTransformer()); o.Output.AddAlias("spreadsheet", "csv"); // both --output:format=csv and --output:format=spreadsheet work});IOutputTransformer receives the handler’s return value and returns a formatted string:
public class CsvOutputTransformer : IOutputTransformer{ public string Name => "csv";
public ValueTask<string> TransformAsync(object? value, CancellationToken ct) { var csv = value is IEnumerable<object> rows ? ToCsv(rows) : value?.ToString() ?? ""; return ValueTask.FromResult(csv); }}Suppressing the banner
Section titled “Suppressing the banner”The startup banner (shown in interactive mode) can be suppressed:
myapp --no-logoOr globally:
app.Options(o =>{ o.Output.BannerEnabled = false; // or: o.Output.BannerFormats = ["human"] — show only in human format (default)});Spectre.Console integration
Section titled “Spectre.Console integration”Add Repl.Spectre and register:
app.UseSpectreConsole(); // enables rich prompts and renderables in one callReturning renderables
Section titled “Returning renderables”Return any IRenderable from a handler — Spectre renders it automatically:
app.Map("contacts table", (IContactStore store) =>{ var table = new Table() .BorderStyle(Style.Parse("grey")) .AddColumn("[bold]Id[/]") .AddColumn("[bold]Name[/]") .AddColumn("[bold]Email[/]");
foreach (var c in store.All()) table.AddRow(c.Id.ToString(), c.Name, c.Email);
return table;});Color palette and style
Section titled “Color palette and style”Use Spectre.Console’s full Markup and Style API anywhere an IRenderable is expected:
return new Markup("[green bold]Success![/] Contact added.");return new Panel(new Markup(content)) .BorderStyle(Style.Parse("blue")) .Header("[bold]Summary[/]");Available renderables
Section titled “Available renderables”| Type | Description |
|---|---|
Table | Grid with borders, alignment, and markup |
Panel | Box with optional header and border |
Tree | Hierarchical tree view |
BarChart | Horizontal bar chart |
BreakdownChart | Proportion chart |
Calendar | Monthly calendar with highlighted dates |
JsonText | Syntax-highlighted JSON |
FigletText | Large ASCII art text |
TextPath | Breadcrumb path rendering |
Markup | Inline styled text |
Grid / Columns | Free-form layout |
Rule | Horizontal divider |
Progress / Status | Live progress widgets |
Detecting Spectre capability
Section titled “Detecting Spectre capability”Spectre.Console detects terminal capabilities automatically. On terminals without ANSI support, all output degrades gracefully to plain text — no code changes needed.
Help output formatting
Section titled “Help output formatting”Help can also be rendered in structured formats:
myapp contacts --help # human-readablemyapp contacts --help --json # machine-readable JSONThe JSON format returns a structured ReplDocumentationModel — useful for tooling, documentation generators, and agents.
IAnsiConsole injection
Section titled “IAnsiConsole injection”Repl.Spectre registers Spectre’s IAnsiConsole in DI, bound to the current session’s output stream. Inject it directly when you need full Spectre control:
app.Map("demo", (IAnsiConsole console) =>{ console.Write(new FigletText("Repl").Color(Color.Blue)); console.MarkupLine("[bold green]Ready.[/]");});This is session-safe in hosted mode — each session gets its own IAnsiConsole bound to its output stream.