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

Use a more robust CLI color detection #74

Merged
merged 1 commit into from
Jun 23, 2023
Merged

Conversation

dani-garcia
Copy link
Member

Type of change

- [x] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Previously we only did a simple check for NO_COLOR to disable the terminal coloring, and we fell back to isatty otherwise. This would cause it to emit colors in dumb interactive terminals, and at the same time it wouldn't allow for a way to force colors while piping the output.

Switching to the supports-color crate, we don't have to do these checks ourselves while also getting others for free:

  • Support for the http://bixense.com/clicolors/ spec, in addition to the https://no-color.org/ spec which we already supported. We can now use CLICOLOR_FORCE=[true|false] to force enable or disable the color regardless of terminal capabilities or interactive status.
  • Support for dumb interactive terminals that can't handle colors properly (TERM=dumb).

@dani-garcia dani-garcia marked this pull request as ready for review June 20, 2023 15:53
@dani-garcia dani-garcia merged commit 32b968e into master Jun 23, 2023
@dani-garcia dani-garcia deleted the better_cli_colors branch June 23, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants