mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
Add colors to statistics output (#2699)
This commit is contained in:
parent
a129181407
commit
417fe4355f
1 changed files with 7 additions and 4 deletions
|
@ -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 {
|
||||||
""
|
""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue