diff options
| author | clippered <clarke_overkill@yahoo.com> | 2017-11-10 07:23:12 +1100 |
|---|---|---|
| committer | clippered <clarke_overkill@yahoo.com> | 2017-11-13 20:18:03 +1100 |
| commit | d2f2f2546358f60c22da98918535cd932589de5c (patch) | |
| tree | 4b78598b640665a878dd7f7489a5a61b2f722133 /src/utils.rs | |
| parent | 8a27a2da622dc51d4cea7378bf95c79ce99ba21e (diff) | |
add cli option for color
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 9 |
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") } |
