Skip to main content

Module output

Module output 

Source
Expand description

Central semantic output module (OSS_SPEC.md §19.4).

Non-contract CLI output (progress, warnings, headers, status lines) should go through this module rather than raw println!/eprintln! so every message is:

  1. Echoed to stderr for humans, leaving stdout reserved for machine-readable output (--json, --help-agent, etc.) — tools piping stdout to jq never see incidental status text.
  2. Mirrored to the always-on tracing file log so we have a trail of what the CLI told the user.
  3. Coloured consistently on a TTY (via a tiny ANSI helper) and plain when stderr is redirected.

Callers that emit machine-readable output (e.g. JSON replies to --json flags) or dedicated discovery surfaces (--help-agent, --debug-agent, zad commands, zad docs, zad man) MUST continue to use raw println! so the contract holds byte-for-byte.

Functions§

error
Renders msg as an error. Does not exit — the caller propagates a Result upward.
header
Renders msg as a prominent header/section separator. Unlike the others, headers include a blank line before the banner.
info
Renders msg as an informational note (same weight as status but typed so future theming can distinguish them).
status
Renders msg as a neutral status line — the default for user-facing progress (“Loaded 4 channels”).
warn
Renders msg as a warning that doesn’t abort the command.