diff options
author | Benjamin Sago <ogham@users.noreply.github.com> | 2021-10-07 22:48:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 22:48:48 +0100 |
commit | 721440b12ef01a812abe5dc6ced69af6e221fad5 (patch) | |
tree | 7f961845b11d2fbaf7d4b8c087558825957d55e3 | |
parent | d30c3dd6e528980ba30d618ca6b9d7f2e8b08e48 (diff) | |
parent | 812cf0ba575ae91e69f0d4f054d3048e7c8b5e5d (diff) |
Add NO_COLOR env support
-rw-r--r-- | src/output.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/output.rs b/src/output.rs index 3579eb4..b776e53 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 |