Skip to content

Commit

Permalink
feat: support NO_COLOR and FORCE_COLOR env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
samypr100 committed Jun 4, 2024
1 parent 314cdbb commit 2c2fbb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ In addition, uv respects the following environment variables:
- `MACOSX_DEPLOYMENT_TARGET`: Used with `--python-platform macos` and related variants to set the
deployment target (i.e., the minimum supported macOS version). Defaults to `12.0`, the
least-recent non-EOL macOS version at time of writing.
- `NO_COLOR`: Disable colors. Takes precedence over `FORCE_COLOR`. See [no-color.org](https://no-color.org).
- `FORCE_COLOR`: Enforce colors regardless of TTY support. See [force-color.org](https://force-color.org).

## Versioning

Expand Down
6 changes: 5 additions & 1 deletion crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ impl GlobalSettings {
Self {
quiet: args.quiet,
verbose: args.verbose,
color: if args.no_color {
color: if args.no_color || std::env::var_os("NO_COLOR").is_some() {
ColorChoice::Never
} else if std::env::var_os("FORCE_COLOR").is_some()
|| std::env::var_os("CLICOLOR_FORCE").is_some()
{
ColorChoice::Always
} else {
args.color
},
Expand Down

0 comments on commit 2c2fbb7

Please sign in to comment.