Skip to content

Commit

Permalink
Respect FORCE_COLOR environment variable (#10315)
Browse files Browse the repository at this point in the history
## Summary

Closes #10303.
  • Loading branch information
charliermarsh authored Jan 6, 2025
1 parent 88b63b1 commit f7fc85f
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 93 deletions.
9 changes: 5 additions & 4 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ pub struct GlobalArgs {
#[arg(global = true, long, hide = true, conflicts_with = "color")]
pub no_color: bool,

/// Control colors in output.
/// Control the use of color in output.
///
/// By default, uv will automatically detect support for colors when writing to a terminal.
#[arg(
global = true,
long,
value_enum,
default_value = "auto",
conflicts_with = "no_color",
value_name = "COLOR_CHOICE"
)]
Expand Down Expand Up @@ -4486,8 +4487,8 @@ pub struct GenerateShellCompletionArgs {
pub quiet: bool,
#[arg(long, short, action = clap::ArgAction::Count, conflicts_with = "quiet", hide = true)]
pub verbose: u8,
#[arg(long, default_value = "auto", conflicts_with = "no_color", hide = true)]
pub color: ColorChoice,
#[arg(long, conflicts_with = "no_color", hide = true)]
pub color: Option<ColorChoice>,
#[arg(long, hide = true)]
pub native_tls: bool,
#[arg(long, hide = true)]
Expand Down
22 changes: 11 additions & 11 deletions crates/uv/tests/it/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn help() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -132,7 +132,7 @@ fn help_flag() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -211,7 +211,7 @@ fn help_short_flag() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -347,9 +347,9 @@ fn help_subcommand() {
(<https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives>)
--color <COLOR_CHOICE>
Control colors in output
Control the use of color in output.
[default: auto]
By default, uv will automatically detect support for colors when writing to a terminal.
Possible values:
- auto: Enables colored output only when the output is going to a terminal or TTY with
Expand Down Expand Up @@ -591,9 +591,9 @@ fn help_subsubcommand() {
(<https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives>)
--color <COLOR_CHOICE>
Control colors in output
Control the use of color in output.
[default: auto]
By default, uv will automatically detect support for colors when writing to a terminal.
Possible values:
- auto: Enables colored output only when the output is going to a terminal or TTY with
Expand Down Expand Up @@ -728,7 +728,7 @@ fn help_flag_subcommand() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -801,7 +801,7 @@ fn help_flag_subsubcommand() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -958,7 +958,7 @@ fn help_with_global_option() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down Expand Up @@ -1074,7 +1074,7 @@ fn help_with_no_pager() {
-v, --verbose...
Use verbose output
--color <COLOR_CHOICE>
Control colors in output [default: auto] [possible values: auto, always, never]
Control the use of color in output [possible values: auto, always, never]
--native-tls
Whether to load TLS certificates from the platform's native certificate store [env:
UV_NATIVE_TLS=]
Expand Down
Loading

0 comments on commit f7fc85f

Please sign in to comment.