Skip to main content

should_colorize

Function should_colorize 

Source
pub fn should_colorize(no_color_present: bool, stream_is_terminal: bool) -> bool
Expand description

Decide whether diagnostic rendering should include ANSI color escapes.

This is the pure decision core (injectable for tests):

  • NO_COLOR (https://no-color.org): the presence of the environment variable — any value, including the empty string — disables color.
  • TTY: color is only used when the stream that carries diagnostics is an interactive terminal. Piped/redirected output (CI logs, agents parsing bock check output) must never contain escape sequences.