From 4325b4397bd4173d09b26189ec66447327922682 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Mon, 24 Jun 2024 10:21:38 -0500 Subject: [PATCH] Enhance deadliners a little --- ChangeLog | 4 ++++ inst/examples/deadliners.r | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a6b2ae8..9ef6eea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-06-24 Dirk Eddelbuettel + + * inst/examples/deadliners.r: A little formatting and colour + 2024-06-12 Dirk Eddelbuettel * inst/examples/deadliners.r: Minimal 'Deadline' field printer diff --git a/inst/examples/deadliners.r b/inst/examples/deadliners.r index a666b33..a7e1ac5 100755 --- a/inst/examples/deadliners.r +++ b/inst/examples/deadliners.r @@ -6,7 +6,23 @@ # # Released under GPL (>= 2) +## borrowed with love from tinytest and marginally extended +.color_str <- function(x, color){ + cmap <- c(cyan=36, red=31, green=32, blue=34, purple=35) + sprintf("\033[0;%dm%s\033[0m", cmap[color], x) +} +.blue <- function(txt) .color_str(txt, "blue") +.purple <- function(txt) .color_str(txt, "purple") + db <- as.data.frame(tools::CRAN_package_db()) dd <- with(db, db[!is.na(Deadline), c("Package", "Version", "Deadline")]) dd <- with(dd, dd[order(Deadline, Package), ]) -print(dd, row.names=FALSE) + +dts <- unique(dd[, "Deadline"]) +for (d in seq_along(dts)) { + cat(.blue(dts[d]), ": ", sep="") + ind <- with(dd, Deadline == dts[d]) + blk <- dd[ind, ] + pv <- paste0(.purple(blk[,1]), " (", blk[,2], ")") + cat(paste(strwrap(paste(pv, collapse=", "), 200), "\n")) +}