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()
)
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".
See also
These functions supports inline markup.
Other functions supporting inline markup:
cli_abort()
,
cli_blockquote()
,
cli_bullets()
,
cli_bullets_raw()
,
cli_dl()
,
cli_h1()
,
cli_li()
,
cli_ol()
,
cli_process_start()
,
cli_progress_along()
,
cli_progress_bar()
,
cli_progress_message()
,
cli_progress_output()
,
cli_progress_step()
,
cli_rule
,
cli_status()
,
cli_status_update()
,
cli_text()
,
cli_ul()
,
format_error()
,
format_inline()