Skip to content

Commit 208d9c7

Browse files
Merge pull request #1187 from olivroy/color
Add colored output
2 parents 634dce1 + 2489092 commit 208d9c7

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

R/communicate.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ communicate_summary <- function(changed, ruler_width) {
2727
cat("Status\tCount\tLegend \n")
2828
cli::cat_bullet(
2929
"\t", sum(!changed, na.rm = TRUE), "\tFile unchanged.",
30-
bullet = "tick"
30+
bullet = "tick",
31+
bullet_col = "green"
3132
)
3233
cli::cat_bullet(
3334
"\t", sum(changed, na.rm = TRUE), "\tFile changed.",
34-
bullet = "info"
35+
bullet = "info",
36+
bullet_col = "cyan"
3537
)
3638
cli::cat_bullet(
37-
bullet = "cross", "\t", sum(is.na(changed)), "\tStyling threw an error."
39+
bullet = "cross", "\t", sum(is.na(changed)), "\tStyling threw an error.",
40+
bullet_col = "red"
3841
)
3942
cli::cat_rule(width = max(40L, ruler_width))
4043
}

R/transform-files.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ transform_file <- function(path,
6666
}
6767
changed <- transform_code(path, fun = fun, ..., dry = dry)
6868

69-
bullet <- if (is.na(changed)) {
70-
"warning"
71-
} else if (changed) {
72-
"info"
73-
} else {
74-
"tick"
75-
}
76-
7769
if (!getOption("styler.quiet", FALSE)) {
78-
cli::cat_bullet(bullet = bullet)
70+
if (is.na(changed)) {
71+
bullet <- "warning"
72+
color <- "red"
73+
} else if (changed) {
74+
bullet <- "info"
75+
color <- "cyan"
76+
} else {
77+
bullet <- "tick"
78+
color <- "green"
79+
}
80+
cli::cat_bullet(bullet = bullet, bullet_col = color)
7981
}
8082
invisible(changed)
8183
}

0 commit comments

Comments
 (0)