r-lib/cli

cli_alert_* truncates a long vector

jzadra opened this issue · 1 comments

When I have vector inlcuded in a cli_alert_* function, it is getting truncated. I don't see any arguments to prevent this.

dat <- c("tidyverse", "tidyxl", "tigris", "tiler", "timechange", "tinytex", 
         "tm", "tokenizers", "tools", "transformr", "trend", "triebeard", 
         "TTR", "tweenr", "tzdb", "units", "unpivotr", "UpSetR", "urlchecker", 
         "urltools", "usdata", "usethis", "utf8", "utils", "uuid", "V8", 
         "vctrs", "viridis", "viridisLite", "visdat", "vroom", "waiter", 
         "waldo", "webfakes", "webshot", "websocket", "wec", "whereami", 
         "whisker", "whoami", "withr", "wk", "wordcloud", "WriteXLS", 
         "xfun", "xlsx", "xlsxjars", "XML", "xml2", "xmlparsedata", "xopen", 
         "xtable", "xts", "yaml", "yulab.utils", "zip", "zoo")

cli::cli_alert_info("Here is a long vector that gets truncated:  {dat}")
#> ℹ Here is a long vector that gets truncated:  tidyverse, tidyxl, tigris, tiler, timechange, tinytex, tm, tokenizers, tools, transformr, trend, triebeard, TTR, tweenr, tzdb, units, unpivotr, UpSetR, …, zip, and zoo

Note that the values between UpSetR and zip are not printed, and instead are replaced by ...

This is as designed. You probably don't want to print an arbitrarily long vector.

Nevertheless you can customize it if you like:

dat <- cli_vec(dat, style = list("vec-trunc" = Inf))
❯ cli::cli_alert_info("Here is a long vector that gets truncated:  {dat}")
ℹ Here is a long vector that gets truncated:  tidyverse, tidyxl, tigris, tiler, timechange, tinytex, tm, tokenizers, tools, transformr, trend, triebeard, TTR, tweenr, tzdb, units, unpivotr, UpSetR, urlchecker, urltools, usdata, usethis, utf8, utils, uuid, V8, vctrs, viridis, viridisLite, visdat, vroom, waiter, waldo, webfakes, webshot, websocket, wec, whereami, whisker, whoami, withr, wk, wordcloud, WriteXLS, xfun, xlsx, xlsxjars, XML, xml2, xmlparsedata, xopen, xtable, xts, yaml, yulab.utils, zip, and zoo