summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Matei Pintilie <lucafulger@gmail.com>2021-08-20 21:36:05 +0200
committerLuca Matei Pintilie <lucafulger@gmail.com>2021-08-20 21:36:05 +0200
commit812cf0ba575ae91e69f0d4f054d3048e7c8b5e5d (patch)
treee78e16f3a89c347308a60e10416057c511860956
parent640818d36e7ed04e2666aba90d0c037787cb9d6c (diff)
Add NO_COLOR env support
-rw-r--r--src/output.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/output.rs b/src/output.rs
index 9ef1fba..6dc9bee 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -2,6 +2,7 @@
use std::fmt;
use std::time::Duration;
+use std::env;
use dns::{Response, Query, Answer, QClass, ErrorCode, WireError, MandatedLength};
use dns::record::{Record, RecordType, UnknownQtype, OPT};
@@ -55,7 +56,7 @@ impl UseColours {
/// overridden the colour setting, and if not, whether output is to a
/// terminal.
pub fn should_use_colours(self) -> bool {
- self == Self::Always || (atty::is(atty::Stream::Stdout) && self != Self::Never)
+ self == Self::Always || (atty::is(atty::Stream::Stdout) && env::var("NO_COLOR").is_err() && self != Self::Never)
}
/// Creates a palette of colours depending on the user’s wishes or whether