Skip to main content

Module color

Module color 

Source
Expand description

Semantic terminal color with standard opt-out.

A small, dependency-free color layer for CLI reporters: a ColorChoice (auto/always/never) resolves — together with the NO_COLOR standard and TTY detection — into an effective on/off Palette. The palette exposes semantic styles (success/error/warn/info/dim/bold) that emit ANSI SGR escapes when enabled and return the plain string when not, so the same rendering code stays byte-clean on pipes and honors user preference.

Structs§

Palette
A resolved, semantic color palette.

Enums§

ColorChoice
A user’s requested color policy, before environment/TTY resolution.

Constants§

NO_COLOR_ENV
The environment variable that, when present (regardless of value), disables color regardless of any explicit choice (the NO_COLOR standard).

Functions§

no_color_env_set
Whether the NO_COLOR environment variable is present.
resolve_color
Resolve a ColorChoice into an effective on/off decision.
resolve_color_with
Pure resolver core: fold an explicit NO_COLOR presence and TTY detection into an effective on/off decision (env-free, so it is unit-testable).