cli_process_expr | R Documentation |
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.
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()
)
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 |
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 |
The result of the evaluated expr
, invisibly.
Other functions extending the cli package:
cli_progress_step_quick()
,
cli_qty_lgl()
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()
set.seed(123)
try(russian_roulette())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.