Skip to content

Commit 02f09d0

Browse files
committed
rename --disable-color to --no-color
And respect NO_COLOR env var
1 parent b4bc1d4 commit 02f09d0

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ http3 = ["dep:h3", "dep:h3-quinn", "dep:quinn-proto", "dep:quinn", "dep:http"]
3434
anyhow = "1.0.86"
3535
average = "0.16.0"
3636
byte-unit = "5.1.4"
37-
clap = { version = "4.5.9", features = ["derive"] }
37+
clap = { version = "4.5.9", features = ["derive", "env"] }
3838
float-ord = "0.3.2"
3939
kanal = "0.1.1"
4040
humantime = "2.1.0"

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,13 @@ Note: if used several times for the same host:port:target_host:target_port, a ra
275275
long = "connect-to"
276276
)]
277277
connect_to: Vec<ConnectToEntry>,
278-
#[arg(help = "Disable the color scheme.", long = "disable-color")]
279-
disable_color: bool,
278+
#[arg(
279+
help = "Disable the color scheme.",
280+
alias = "disable-color",
281+
long = "no-color",
282+
env = "NO_COLOR"
283+
)]
284+
no_color: bool,
280285
#[cfg(unix)]
281286
#[arg(
282287
help = "Connect to a unix socket instead of the domain in the URL. Only for non-HTTPS URLs.",
@@ -625,8 +630,7 @@ pub async fn run(mut opts: Opts) -> anyhow::Result<()> {
625630
let print_config = {
626631
let mode = opts.output_format.unwrap_or_default();
627632

628-
let disable_style =
629-
opts.disable_color || !std::io::stdout().is_tty() || opts.output.is_some();
633+
let disable_style = opts.no_color || !std::io::stdout().is_tty() || opts.output.is_some();
630634

631635
let output: Box<dyn std::io::Write + Send + 'static> = if let Some(output) = opts.output {
632636
Box::new(File::create(output)?)
@@ -760,7 +764,7 @@ pub async fn run(mut opts: Opts) -> anyhow::Result<()> {
760764
report_receiver: result_rx,
761765
start,
762766
fps: opts.fps,
763-
disable_color: opts.disable_color,
767+
disable_color: opts.no_color,
764768
time_unit: opts.time_unit,
765769
}
766770
.monitor(),

0 commit comments

Comments
 (0)