From a87e071b5e303ec3d547cc9d7e9b67437e8bc40a Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 22 Jan 2024 22:56:51 -0600 Subject: [PATCH] Add `--no-color` support for `pip` compatibility (#1048) Adds `--no-color` as provided by `pip`. See #1049 for follow-up. --- crates/puffin/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/puffin/src/main.rs b/crates/puffin/src/main.rs index 06b87ea44..9d72db1b2 100644 --- a/crates/puffin/src/main.rs +++ b/crates/puffin/src/main.rs @@ -57,6 +57,10 @@ struct Cli { #[arg(global = true, long, short, conflicts_with = "quiet")] verbose: bool, + /// Disable colors. + #[arg(global = true, long)] + no_color: bool, + #[command(flatten)] cache_args: CacheArgs, } @@ -552,6 +556,10 @@ async fn inner() -> Result { puffin_warnings::enable(); } + if cli.no_color { + anstream::ColorChoice::write_global(anstream::ColorChoice::Never); + } + miette::set_hook(Box::new(|_| { Box::new( miette::MietteHandlerOpts::new()