Skip to content

Commit

Permalink
Merge pull request #27 from hartwork/support-no-color
Browse files Browse the repository at this point in the history
Support `NO_COLOR` environment variable
  • Loading branch information
hartwork authored Jun 18, 2023
2 parents 843a748 + 632be6a commit 2f75aae
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 2f75aae

Please sign in to comment.