Expand description
Unified output abstraction for commands that support both human-readable and JSON output.
Commands construct an Output from their --output format and the global
--quiet flag, then route all output through it:
Output::readableruns its closure only in human-readable mode, handing it aPrintfor progress/status messages and text rendering.Output::json/Output::json_valuerun only in JSON mode and write the final machine-readable result to stdout.
Output adds no buffering of its own: each call writes straight to
stdout/stderr as it happens rather than accumulating a buffer to flush at the
end, so long-running operations don’t hold their progress back. (The OS may
still buffer a redirected or piped stream, as usual.)
Structs§
- Output
- Wraps the output
Formatand aPrint(carrying--quiet) so commands can emit human-readable and JSON output through a single value.
Enums§
- Format
- The format a command should render its output in.
Functions§
- error_
json - Build the canonical JSON error envelope for an error:
{ "error": { "type": …, "message": … } }.