fix: support colour output in CI via FORCE_COLOR/CLICOLOR_FORCE - #622
Open
NickJosevski wants to merge 2 commits into
Open
fix: support colour output in CI via FORCE_COLOR/CLICOLOR_FORCE#622NickJosevski wants to merge 2 commits into
NickJosevski wants to merge 2 commits into
Conversation
Colour was gated solely on term.IsTerminal(stdout), which never resolves to true in a CI job, so CI systems that do render ANSI codes (GitHub Actions, GitLab CI) could never show coloured output. Honour the conventional CLICOLOR_FORCE and FORCE_COLOR opt-ins, keeping NO_COLOR as the highest-precedence override. Terminal detection remains the default so existing non-CI behaviour is unchanged, and CI output stays plain unless explicitly opted in. Fixes #506 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NickJosevski
marked this pull request as ready for review
August 4, 2026 07:48
YuKitsune
requested changes
Aug 5, 2026
YuKitsune
left a comment
There was a problem hiding this comment.
I ran this locally and noticed the Octopus logo was still appearing in cyan. Taking a look at color.go, many of the functions there ignore the IsColorEnabled flag. Is this intentional?
Setting one of the force variables to 0 fell through to terminal detection, so `FORCE_COLOR=0 octopus --help` in a terminal still printed the cyan Octopus logo. Both bixense.com/clicolors and the de facto FORCE_COLOR convention treat 0 as an instruction to disable colour, so an explicitly set force variable now overrides terminal detection in both directions. CLICOLOR=0 is honoured for the same reason. Terminal detection is now injected into the decision function so the table can be tested with and without a TTY, and tests assert that every exported helper in color.go honours IsColorEnabled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I'm still testing this myself... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #506
Problem
Colour was gated solely on
term.IsTerminal(os.Stdout.Fd()), which never resolves to true inside a CI job. CI systems that do render ANSI codes — GitHub Actions, GitLab CI — could therefore never show coloured output.Change
pkg/output/color.gonow follows the conventions from no-color.org and bixense.com/clicolors:NO_COLORset to anything non-emptyCLICOLOR_FORCEorFORCE_COLORset to anything but0This is opt-in, so CI output stays plain unless asked for. Auto-enabling on a
CIenv var would inject escape codes into the logs of systems that don't render them, and would break anyone currently parsing CLI output in a pipeline.Verification
Unit tests cover the precedence matrix. Manually against a build:
README documents the variables under Getting Started.
🤖 Generated with Claude Code