Skip to main content

Module output

Module output 

Source
Expand description

Output rendering.

Five formats, selected by the global --format/-o flag. When the flag and the config file both leave the format unset, the default is TTY-aware: table when stdout is a terminal (interactive use), json otherwise (piped / agent invocations). See crate::context::GlobalArgs::resolve_output.

  • table: comfy-table with UTF-8 borders for humans on a TTY.
  • json: pretty-printed JSON via serde_json.
  • yaml: YAML via serde_yml — same shape as JSON.
  • md: GitHub-flavored markdown tables (same data, markdown borders).
  • toon: Token-Oriented Object Notation (toon-format crate, default opts).

The Render trait is only used for table and md. The other three formats serialize directly off Serialize.

Color is suppressed when any of: --no-color, NO_COLOR env, TERM=dumb, stdout is not a TTY, or the format is anything other than table.

State-change confirmations go to stderr through OutputCtx::note, and advisory warnings through OutputCtx::warn; only --quiet suppresses them.

Structs§

OutputCtx
Carries the user’s output preferences and TTY state.

Enums§

Format
Output format selected by --format/-o.

Traits§

Render
Trait every printable response implements.

Functions§

bool_cell
Helper for boolean cells: ✓ / ✗ / —.
emit
Top-level emit: serializes through the chosen format.
new_table
Builds a fresh table.
opt_cell
Helper: a Cell whose text is value.map_or("—", |v| &v.to_string()).
set_header_bold
Sets the table header docker/kubectl-style: ALL-CAPS bold cells (bold only when colors are active — otherwise we’d dump raw ANSI escapes into piped output). Callers should pass already-uppercased strings.
write_pagination_footer
Writes a "showing X–Y of Z" footer below a list-style table. Handles the empty-page case (page_len == 0) without underflowing to "1-0 of N".
write_table
Writes table to w.