This function is superseded in favor of cli_progress_step_quick()
and the underlying cli::cli_progress_*
family of functions which are more powerful and
versatile than the cli::cli_process_*
family on which cli_process_expr()
is built.
Usage
cli_process_expr(
expr,
msg,
msg_done = paste(msg, "... done"),
msg_failed = paste(msg, "... failed"),
msg_class = "alert-info",
done_class = "alert-success",
failed_class = "alert-danger",
env = parent.frame()
)
Arguments
- expr
An expression to be evaluated.
- msg
The message to show to indicate the start of the process or computation. It will be collapsed into a single string, and the first line is kept and cut to
console_width()
.- msg_done
The message to use for successful termination.
- msg_failed
The message to use for unsuccessful termination.
- msg_class
The style class to add to the message. Use an empty string to suppress styling.
- done_class
The style class to add to the successful termination message. Use an empty string to suppress styling.a
- failed_class
The style class to add to the unsuccessful termination message. Use an empty string to suppress styling.a
- env
Default environment to evaluate
expr
, as well as possible glue expressions withinmsg
, in.
See also
Other functions extending the cli package:
cli_progress_step_quick()
,
cli_qty_lgl()
Examples
if (interactive()) {
pal::cli_process_expr(Sys.sleep(3L), "Zzzz")
}
russian_roulette <- function() {
msg <- "Spinning the cylinder \U0001F91E … "
pal::cli_process_expr(msg = msg,
msg_done = paste0(msg, "and pulling the trigger – lucky again. \U0001F60C"),
msg_failed = paste0(msg, "and pulling the trigger – head blast!"),
expr = {
if (interactive()) Sys.sleep(1)
if (runif(1L) < 0.4) stop("\U0001F92F\u2620")
})
}
set.seed(321)
russian_roulette()
#> ℹ Spinning the cylinder 🤞 …
#> ✔ Spinning the cylinder 🤞 … and pulling the trigger – lucky again. 😌
#>
set.seed(123)
try(russian_roulette())
#> ℹ Spinning the cylinder 🤞 …
#> ✖ Spinning the cylinder 🤞 … and pulling the trigger – head blast!
#>
#> Error in rlang::eval_tidy(expr = { : 🤯☠