Check term supports colour before printing fancy diffs

For a terminal like DUMB, we were still attempting to print colourful
diffs, which failed with a `NotSupported` error.

Fixes 
This commit is contained in:
Kamal Marhubi 2016-08-26 17:08:47 -04:00
parent 59e199b439
commit 05882314f5

View File

@ -89,7 +89,9 @@ pub fn print_diff<F>(diff: Vec<Mismatch>, get_section_title: F)
where F: Fn(u32) -> String
{
match term::stdout() {
Some(_) if isatty() => print_diff_fancy(diff, get_section_title, term::stdout().unwrap()),
Some(ref t) if isatty() && t.supports_color() => {
print_diff_fancy(diff, get_section_title, term::stdout().unwrap())
}
_ => print_diff_basic(diff, get_section_title),
}