Skip to main content

Module output

Module output 

Source
Expand description

Output mode control: ANSI, plain text, or structured data.

OutputMode controls how rendering behaves, from terminal colors to JSON serialization. This is the mechanism behind the --output CLI flag.

§Output Mode Categories

CategoryModesTemplate?ANSI?
TemplatedAuto, Term, TextYesVaries
DebugTermDebugYesTags kept as [name]...[/name]
StructuredJson, Yaml, Xml, CsvNo — serializes directlyNo

§How Modes Are Selected

  1. Default: Auto — detects terminal capabilities at render time
  2. CLI flag: --output=json overrides to structured mode
  3. Programmatic: Pass explicit mode to render functions

§Auto Mode Resolution

Auto queries terminal capabilities via the console crate:

  • TTY with color support → behaves like Term (ANSI codes applied)
  • Piped output or no color support → behaves like Text (tags stripped)

This detection happens at render time, not startup.

§Structured Modes

JSON, YAML, XML, and CSV modes skip template rendering entirely. Handler data is serialized directly, which means:

  • Template content is ignored
  • Style tags never apply
  • Context injection is skipped

Use render_auto to automatically dispatch between templated and structured rendering based on output mode.

Enums§

OutputDestination
Destination for rendered output.
OutputMode
Controls how output is rendered.

Functions§

write_binary_output
Writes binary content to the specified destination.
write_output
Writes text content to the specified destination.