when `TERM=dumb`, the output is colorless
comply to
@@ -7,6 +7,7 @@ use ansi_term::Colour::{Green, Red, Yellow};
#[cfg(feature = "color")]
use atty;
use std::fmt;
+use std::env;
#[doc(hidden)]
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -41,6 +42,9 @@ pub struct Colorizer {
macro_rules! color {
($_self:ident, $c:ident, $m:expr) => {
+ if env::var("TERM").ok() == Some(String::from("dumb")) {
+ Format::None($m)
+ } else {
match $_self.when {
ColorWhen::Auto => if is_a_tty($_self.use_stderr) {
Format::$c($m)
@@ -50,6 +54,7 @@ macro_rules! color {
ColorWhen::Always => Format::$c($m),
ColorWhen::Never => Format::None($m),
}
+ }
};
}
