Should CI environments infer `ColorChoice::Always`?
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 171
- Forks
- 44
- Avg merge
- 2h 34m
- Merged PRs (30d)
- 6
Description
Context: I was trying to figure out why CI environments (i.e. CI=true and similar) weren't being colorized by default when using anstream to plumb output containing ANSI colors. I ended up on this choice implementation:
If my read of that helper is right, the current logic only considers anstyle_query::is_ci() after raw.is_terminal() is satisfied. In practice that means that ColorChoice::Always branch won't be taken for CI environments, since (AFAIK) most CI environments don't actually provide a terminal (they support ANSI color codes, but they won't provide a true pty that would pass is is_terminal() check).
Given that, does it makes sense to split that check out, so that is_ci() becomes a sufficient condition for ColorChoice::Always? My intuition is "yes" (since the CI check seems to be a no-op as is), but there's also some nuance given that CI environments aren't real terminals and might only support a small subset of the escapes normally accepted by terminals (things like OSC codes in particular).
So, I don't have a super clear sense here, but I figured I'd open this in case others have a clearer picture than I do 😅. If this change makes sense, I'd be happy to send a PR for it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading crates/anstream/src/auto.rs at the linked lines and trace how raw.is_terminal() and anstyle_query::is_ci() determine the color choice. Resolve whether CI alone should select ColorChoice::Always, including the noted ANSI and OSC-code concerns, and verify the resulting behavior in CI and non-terminal environments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100