Skip to main content

Module style

Module style 

Source
Expand description

Tasteful terminal styling for Heddle CLI output.

Heddle’s brand voice (“precise, calm, conversational”) translates to a deliberately restrained terminal palette: dim/bright contrast and bold weight do most of the structural work; saturated color appears only at semantic seams (success/warning/error, confidence band, identity vs. id). No rainbow output, no syntax highlighting density.

Color decisions are made once at CLI startup via init_from_cli, which consults — in precedence order:

  1. --no-color CLI flag (force off)
  2. NO_COLOR env var (per https://no-color.org) — force off
  3. CLICOLOR_FORCE=1 env var — force on, even on a non-TTY
  4. stdout isatty — auto-detected default

The decision is stored in a process-wide [OnceLock] so render sites consult a bool rather than re-querying the environment per line. JSON output is always uncolored; that decision happens at the print site, not here — should_output_json short-circuits before any styled helper runs.

Functions§

accent
Success/positive/current — warm sage/green (ANSI 8-bit 71).
bold
Structural emphasis — intent text, headers, the principal name.
change_id
Change-id styling: dim. We don’t apply a monospace marker here — terminals already render text monospaced. The “dim+monospace” label in the spec was about visual treatment, which the terminal grants for free.
color_enabled
Returns the active color decision. If init_from_cli was never called (e.g. in a library test that bypasses main), this defaults to false to avoid leaking escapes.
confidence
Confidence band: maps the recorded numeric value to a semantic color. Render the formatted text yourself (e.g. via format_confidence) and pass it here; this keeps the formatting rule in repo and the styling rule here.
count
Render a compact count with the number emphasized.
dim
De-emphasis — used for IDs, timestamps, paths, and other text that’s structurally important but shouldn’t draw the eye.
error
Hard error — muted rust (ANSI 8-bit 167).
error_marker
Small failure status marker.
field
Render a calm label/value row.
init_from_cli
Resolve the color decision once at CLI startup.
ok_marker
Small successful status marker. Keep the word short so it scans like a status glyph but still works in plain terminals.
principal
Principal styling: name in bold, email dimmed. Returns the pre-composed "Name <email>" string so callers don’t have to thread two fragments through println! arguments.
section
Section heading used for human output blocks.
thread_state
Thread-state styling: active/ready/promoted are accent; merged/abandoned are dim (historical, not current); blocked/stale/draft are warn. Unknown variants fall back to plain text. The matcher is case-insensitive against the Display form so callers can pass state.to_string() directly.
warn
Mid-warning — warm amber (ANSI 8-bit 178).
warn_marker
Small warning status marker.
working_marker
Small in-progress status marker.