Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FORCE_COLOR env var #10839

Merged
merged 2 commits into from Apr 8, 2024
Merged

Support FORCE_COLOR env var #10839

merged 2 commits into from Apr 8, 2024

Conversation

carljm
Copy link
Contributor

@carljm carljm commented Apr 8, 2024

Fixes #5499

Summary

Add support for FORCE_COLOR env var, as specified at https://force-color.org/

Test Plan

I wrote an integration test for this, and then realized that can't work, since we use a dev-dependency on colored with the no-color feature to avoid ANSI color codes in test snapshots.

So this is just tested manually.

cargo run --features test-rules -- check --no-cache --isolated - --select RUF901 --diff < /dev/null shows a colored diff.
cargo run --features test-rules -- check --no-cache --isolated - --select RUF901 --diff < /dev/null | less does not have color, since we pipe it to less.
FORCE_COLOR=1 cargo run --features test-rules -- check --no-cache --isolated - --select RUF901 --diff < /dev/null | less does have color (after this diff), even though we pipe it to less.

@carljm carljm added the cli Related to the command-line interface label Apr 8, 2024
@carljm carljm changed the title Cjm/force color Support FORCE_COLOR Apr 8, 2024
@carljm carljm changed the title Support FORCE_COLOR Support FORCE_COLOR env var Apr 8, 2024
Copy link

github-actions bot commented Apr 8, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@carljm carljm merged commit 42d52eb into main Apr 8, 2024
17 checks passed
@carljm carljm deleted the cjm/force-color branch April 8, 2024 21:29
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
Fixes astral-sh#5499 

## Summary

Add support for `FORCE_COLOR` env var, as specified at
https://force-color.org/

## Test Plan

I wrote an integration test for this, and then realized that can't work,
since we use a dev-dependency on `colored` with the `no-color` feature
to avoid ANSI color codes in test snapshots.

So this is just tested manually.

`cargo run --features test-rules -- check --no-cache --isolated -
--select RUF901 --diff < /dev/null` shows a colored diff.
`cargo run --features test-rules -- check --no-cache --isolated -
--select RUF901 --diff < /dev/null | less` does not have color, since we
pipe it to `less`.
`FORCE_COLOR=1 cargo run --features test-rules -- check --no-cache
--isolated - --select RUF901 --diff < /dev/null | less` does have color
(after this diff), even though we pipe it to `less`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support FORCE_COLOR env var
2 participants