From 2e008036229550bbb60fc840184f4dbf99788371 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 27 Mar 2024 13:52:26 -0400 Subject: [PATCH 1/2] Add color to log --- R/communicate.R | 9 ++++++--- R/transform-files.R | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/R/communicate.R b/R/communicate.R index 5b1ca30a0..6cd00d385 100644 --- a/R/communicate.R +++ b/R/communicate.R @@ -27,14 +27,17 @@ communicate_summary <- function(changed, ruler_width) { cat("Status\tCount\tLegend \n") cli::cat_bullet( "\t", sum(!changed, na.rm = TRUE), "\tFile unchanged.", - bullet = "tick" + bullet = "tick", + bullet_col = "green" ) cli::cat_bullet( "\t", sum(changed, na.rm = TRUE), "\tFile changed.", - bullet = "info" + bullet = "info", + bullet_col = "cyan" ) cli::cat_bullet( - bullet = "cross", "\t", sum(is.na(changed)), "\tStyling threw an error." + bullet = "cross", "\t", sum(is.na(changed)), "\tStyling threw an error.", + bullet_col = "red" ) cli::cat_rule(width = max(40L, ruler_width)) } diff --git a/R/transform-files.R b/R/transform-files.R index a4717e015..cb206b271 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -66,16 +66,18 @@ transform_file <- function(path, } changed <- transform_code(path, fun = fun, ..., dry = dry) - bullet <- if (is.na(changed)) { - "warning" - } else if (changed) { - "info" - } else { - "tick" - } - if (!getOption("styler.quiet", FALSE)) { - cli::cat_bullet(bullet = bullet) + if (is.na(changed)) { + bullet <- "warning" + color <- "red" + } else if (changed) { + bullet <- "info" + color <- "cyan" + } else { + bullet <- "tick" + color <- "green" + } + cli::cat_bullet(bullet = bullet, bullet_col = color) } invisible(changed) } From 2489092d3cde39400fa2b0b28a4ce5a2e625b83a Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 27 Mar 2024 14:00:31 -0400 Subject: [PATCH 2/2] style --- R/transform-files.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/transform-files.R b/R/transform-files.R index cb206b271..28dc79c50 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -68,7 +68,7 @@ transform_file <- function(path, if (!getOption("styler.quiet", FALSE)) { if (is.na(changed)) { - bullet <- "warning" + bullet <- "warning" color <- "red" } else if (changed) { bullet <- "info"