Skip to content

Commit

Permalink
Support NO_COLOR environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Jun 18, 2023
1 parent 843a748 commit 632be6a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::exec::run_command;
use crate::network::{wait_for_service, TimeoutSeconds};
use anstream::RawStream;
use clap::{ArgMatches, ColorChoice};
use std::env;
use std::env::args_os;
use std::ffi::OsString;
use std::process::exit;
Expand All @@ -20,7 +21,11 @@ fn main() {
let argv = args_os();
let stdout: &mut dyn RawStream = &mut std::io::stdout();
let stderr: &mut dyn RawStream = &mut std::io::stderr();
let color_choice = ColorChoice::Auto;
let color_choice = if env::var("NO_COLOR").unwrap_or(String::new()).is_empty() {
ColorChoice::Auto
} else {
ColorChoice::Never
};
let exit_code = middle_main(argv, stdout, stderr, color_choice);
exit(exit_code);
}
Expand Down

0 comments on commit 632be6a

Please sign in to comment.