Alerts are typically short status messages.
Usage
cli_alert(text, id = NULL, class = NULL, wrap = FALSE, .envir = parent.frame())
cli_alert_success(
text,
id = NULL,
class = NULL,
wrap = FALSE,
.envir = parent.frame()
)
cli_alert_danger(
text,
id = NULL,
class = NULL,
wrap = FALSE,
.envir = parent.frame()
)
cli_alert_warning(
text,
id = NULL,
class = NULL,
wrap = FALSE,
.envir = parent.frame()
)
cli_alert_info(
text,
id = NULL,
class = NULL,
wrap = FALSE,
.envir = parent.frame()
)
Arguments
- text
Text of the alert.
- id
Id of the alert element. Can be used in themes.
- class
Class of the alert element. Can be used in themes.
- wrap
Whether to auto-wrap the text of the alert.
- .envir
Environment to evaluate the glue expressions in.
Details
Success
nbld <- 11
tbld <- prettyunits::pretty_sec(5.6)
cli_alert_success("Built {.emph {nbld}} status report{?s} in {tbld}.")
#> ✔ Built 11 status reports in 5.6s.
Info
cfl <- "~/.cache/files/latest.cache"
cli_alert_info("Updating cache file {.path {cfl}}.")
#> ℹ Updating cache file ~/.cache/files/latest.cache.
Warning
cfl <- "~/.cache/files/latest.cache"
cli_alert_warning("Failed to update cache file {.path {cfl}}.")
#> ! Failed to update cache file ~/.cache/files/latest.cache.
Danger
cfl <- "~/.config/report.yaml"
cli_alert_danger("Cannot validate config file at {.path {cfl}}.")
#> ✖ Cannot validate config file at ~/.config/report.yaml.
Text wrapping
Alerts are printed without wrapping, unless you set wrap = TRUE
:
cli_alert_info("Data columns: {.val {names(mtcars)}}.")
cli_alert_info("Data columns: {.val {names(mtcars)}}.", wrap = TRUE)
#> ℹ Data columns: "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "g #> ear", and "carb". #> ℹ Data columns: "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", #> "vs", "am", "gear", and "carb".