Skip to content

feat: respect NO_COLOR and strip ANSI when piped #15

@codesoda

Description

@codesoda

Problem

ANSI color codes are hardcoded throughout the CLI output. Colors are emitted even when:

  • stdout is piped to a file or another process
  • the NO_COLOR env var is set (community standard: https://no-color.org)

What to implement

  1. NO_COLOR support: when NO_COLOR is set (any value), suppress all ANSI escape sequences
  2. TTY detection: when stdout is not a terminal, strip ANSI automatically
  3. Apply to all output in main.rs and claude_code.rs where ANSI codes are used

Approach

Add a helper (e.g. in a small output.rs module or inline):

fn color_enabled() -> bool {
    std::io::stdout().is_terminal() && std::env::var("NO_COLOR").is_err()
}

Then gate the existing ANSI escape constants on this check.

Files to touch

  • src/main.rs — version banner, test output, summary formatting
  • src/claude_code.rs — provider output formatting (lines 8-28 define color constants)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions