From d2f2f2546358f60c22da98918535cd932589de5c Mon Sep 17 00:00:00 2001 From: clippered Date: Fri, 10 Nov 2017 07:23:12 +1100 Subject: add cli option for color --- src/rustfmt_diff.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/rustfmt_diff.rs') 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(diff: Vec, get_section_title: F) +pub fn print_diff(diff: Vec, 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), -- cgit 1.4.1-3-g733a5