Add colors to statistics output (#2699)

This commit is contained in:
Charlie Marsh 2023-02-09 19:40:29 -05:00 committed by GitHub
parent a129181407
commit 417fe4355f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -400,18 +400,21 @@ impl<'a> Printer<'a> {
.unwrap(); .unwrap();
let any_fixable = statistics.iter().any(|statistic| statistic.fixable); let any_fixable = statistics.iter().any(|statistic| statistic.fixable);
let fixable = format!("[{}] ", "*".cyan());
let unfixable = "[ ] ";
// By default, we mimic Flake8's `--statistics` format. // By default, we mimic Flake8's `--statistics` format.
for statistic in statistics { for statistic in statistics {
writeln!( writeln!(
stdout, stdout,
"{:>count_width$}\t{:<code_width$}\t{}{}", "{:>count_width$}\t{:<code_width$}\t{}{}",
statistic.count, statistic.count.to_string().bold(),
statistic.code, statistic.code.red().bold(),
if any_fixable { if any_fixable {
if statistic.fixable { if statistic.fixable {
"[*] " &fixable
} else { } else {
"[ ] " unfixable
} }
} else { } else {
"" ""