about summary refs log tree commit diff
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 999ba9f67b9..68fca8789d3 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -15,6 +15,7 @@ use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMet
                   NestedMetaItemKind, Path, Visibility};
 use syntax::codemap::{BytePos, Span, NO_EXPANSION};
 
+use config::Color;
 use rewrite::RewriteContext;
 use shape::Shape;
 
@@ -484,6 +485,14 @@ pub fn isatty() -> bool {
     }
 }
 
+pub fn iscolored(color: Color) -> bool {
+    match color {
+        Color::Always => true,
+        Color::Never => false,
+        Color::Auto => isatty(),
+    }
+}
+
 pub fn starts_with_newline(s: &str) -> bool {
     s.starts_with('\n') || s.starts_with("\r\n")
 }