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/rustfmt_diff.rs | |
| parent | 8a27a2da622dc51d4cea7378bf95c79ce99ba21e (diff) | |
add cli option for color
Diffstat (limited to 'src/rustfmt_diff.rs')
| -rw-r--r-- | src/rustfmt_diff.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs index c0aca68fe2f..858fb876f6e 100644 --- a/src/rustfmt_diff.rs +++ b/src/rustfmt_diff.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use config::Color; use diff; use std::collections::VecDeque; use std::io; use term; -use utils::isatty; +use utils::iscolored; #[derive(Debug, PartialEq)] pub enum DiffLine { @@ -96,12 +97,12 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma results } -pub fn print_diff<F>(diff: Vec<Mismatch>, get_section_title: F) +pub fn print_diff<F>(diff: Vec<Mismatch>, get_section_title: F, color: Color) where F: Fn(u32) -> String, { match term::stdout() { - Some(ref t) if isatty() && t.supports_color() => { + Some(ref t) if iscolored(color) && t.supports_color() => { print_diff_fancy(diff, get_section_title, term::stdout().unwrap()) } _ => print_diff_basic(diff, get_section_title), |
