The output system controls how command results are serialized and rendered to the user. It supports multiple built-in formats, custom transformers, ANSI detection, and banner rendering.
Large result flow and paging are documented separately in Result Flow And Paging.
The active output format is resolved in this order:
- Explicit
--output:formatflag on the command line. ReplOptions.Output.DefaultFormatconfigured at startup."human"(the built-in default).
| Format | Description |
|---|---|
human |
Plain text, intended for terminals. |
spectre |
Lightweight Spectre.Console rendering for terminals. |
json |
JSON serialization. |
xml |
XML serialization. |
yaml |
YAML serialization. |
markdown |
Markdown table/document rendering. |
The built-in aliases are:
--human->human--json->json--xml->xml--yaml/--yml->yaml--markdown->markdown
When Repl.Spectre is enabled, it also registers:
--spectre->spectre
Additional aliases can be registered.
Implement IOutputTransformer and register it to add a new format:
app.Configure<OutputOptions>(o =>
{
o.AddTransformer("csv", new CsvTransformer());
});The transformer receives the command result object and writes formatted output to the provided stream.
Map an alias to any registered format name:
app.Configure<OutputOptions>(o =>
{
o.AddAlias("spreadsheet", "csv");
});ANSI color and styling support is resolved through a chain of checks:
- Session override — a hosted session can force ANSI on or off.
- Explicit
AnsiMode— set viaOutputOptions.AnsiMode. - Environment variables —
NO_COLOR(disables),CLICOLOR_FORCE(enables),TERM(checked fordumb). - Redirection check — if stdout is redirected to a file or pipe, ANSI is disabled.
The first check that produces a definitive answer wins.
Terminal-sequence emitters (shell-integration marks, advanced progress) and Spectre rendering add one shared fallback on top: a hosted client that advertises ANSI purely through capability flags (terminal identity, control messages) is honored even when the server console's own state says no — the environment escape hatches above always win. Spectre rendering (the spectre format and injected IAnsiConsole instances) follows the same verdict: colors degrade to plain text when ANSI is off, and Unicode box drawing falls back to safe borders when the output sink's encoding cannot carry the glyphs. See Terminal Shell Integration for the gate order.
The startup banner is controlled by:
OutputOptions.BannerEnabled— master toggle (defaulttrue).BannerFormats— set of format names that allow the banner (typicallyhumanonly).--no-logoflag — suppresses the banner for the current invocation.
The banner is only rendered when the active format is in the BannerFormats set and BannerEnabled is true.
--help uses the active output format:
humanrenders the classic text help.spectrerenders dedicated Spectre help.- Structured formats (
json,xml,yaml,markdown) use the machine-readable help pipeline.
The output width used for wrapping and table layout is resolved as:
OutputOptions.PreferredWidthif set explicitly.- Detected terminal width.
OutputOptions.FallbackWidth(default120).
In interactive mode, when ANSI is supported, JSON output is syntax-highlighted automatically. This applies only to the json format rendered to a terminal — redirected or non-ANSI output remains plain.
Human terminal formats (human and spectre) can use the integrated result pager when rendered output exceeds the visible row capacity or a result-flow page source has more data. The pager is never used for redirected stdout, protocol passthrough, MCP/programmatic execution, or machine formats.
Paged handler results should return ReplPage<T> through IReplPagingContext. JSON serializes these as { items, pageInfo }; human and Spectre formats render the current page plus continuation metadata.
- Configuration Reference —
OutputOptionsproperties. - Execution Pipeline — output formatting occurs at stage 11.
- Result Flow And Paging - paging contracts, CLI flags, and MCP behavior.