wrapped cli functions
wrapped_cli.Rd
These are wrapped versions of cli methods. The wrapper inserts a condition handler that produces log data.
Usage
cli_abort(
message,
...,
call = .envir,
.envir = parent.frame(),
.frame = .envir
)
cli_alert(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_info(
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_warning(
text,
id = NULL,
class = NULL,
wrap = FALSE,
.envir = parent.frame()
)
cli_blockquote(
quote,
citation = NULL,
id = NULL,
class = NULL,
.envir = parent.frame()
)
cli_bullets(text, id = NULL, class = NULL, .envir = parent.frame())
cli_bullets_raw(text, id = NULL, class = NULL)
cli_code(
lines = NULL,
...,
language = "R",
.auto_close = TRUE,
.envir = environment()
)
cli_div(
id = NULL,
class = NULL,
theme = NULL,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_dl(
items = NULL,
labels = names(items),
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_end(id = NULL)
cli_h1(text, id = NULL, class = NULL, .envir = parent.frame())
cli_h2(text, id = NULL, class = NULL, .envir = parent.frame())
cli_h3(text, id = NULL, class = NULL, .envir = parent.frame())
cli_inform(message, ..., .envir = parent.frame())
cli_li(
items = NULL,
labels = names(items),
id = NULL,
class = NULL,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_ol(
items = NULL,
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_progress_message(
msg,
current = TRUE,
.auto_close = TRUE,
.envir = parent.frame(),
...
)
cli_progress_output(text, id = NULL, .envir = parent.frame())
cli_progress_step(
msg,
msg_done = msg,
msg_failed = msg,
spinner = FALSE,
class = if (!spinner) ".alert-info",
current = TRUE,
.auto_close = TRUE,
.envir = parent.frame(),
...
)
cli_rule(
left = "",
center = "",
right = "",
id = NULL,
.envir = parent.frame()
)
cli_text(..., .envir = parent.frame())
cli_ul(
items = NULL,
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_vec(x, style = list())
cli_verbatim(..., .envir = parent.frame())
cli_warn(message, ..., .envir = parent.frame())
Arguments
- message
It is formatted via a call to
cli_bullets()
.- ...
Passed to
rlang::abort()
,rlang::warn()
orrlang::inform()
.- call
The execution environment of a currently running function, e.g.
call = caller_env()
. The corresponding function call is retrieved and mentioned in error messages as the source of the error.You only need to supply
call
when throwing a condition from a helper function which wouldn't be relevant to mention in the message.Can also be
NULL
or a defused function call to respectively not display any call or hard-code a code to display.For more information about error calls, see Including function calls in error messages.
- .envir
Environment to evaluate the glue expressions in.
- .frame
The throwing context. Used as default for
.trace_bottom
, and to determine the internal package to mention in internal errors when.internal
isTRUE
.- 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.
- quote
Text of the quotation.
- citation
Source of the quotation, typically a link or the name of a person.
- lines
Character vector, each line will be a line of code, and newline characters also create new lines. Note that no glue substitution is performed on the code.
- language
Programming language. This is also added as a class, in addition to
code
.- .auto_close
Passed to
cli_div()
when creating the container of the code. By default the code container is closed after emittinglines
and...
viacli_verbatim()
. You can keep that container open with.auto_close
and/or.envir
, and then callingcli_verbatim()
to add (more) code. Note that the code will be formatted and syntax highlighted separately for eachcli_verbatim()
call.- theme
A custom theme for the container. See themes.
- items
Named character vector, or
NULL
. If notNULL
, they are used as list items.- labels
Item labels. Defaults the names in
items
.- .close
Whether to close the list container if the
items
were specified. IfFALSE
then new items can be added to the list.- msg
Message to show. It may contain glue substitution and cli styling. It can be updated via
cli_progress_update()
, as usual.- current
Passed to
cli_progress_bar()
.- msg_done
Message to show on successful termination. By default this it is the same as
msg
and it is styled as a cli success alert (seecli_alert_success()
).- msg_failed
Message to show on unsuccessful termination. By default it is the same as
msg
and it is styled as a cli danger alert (seecli_alert_danger()
).- spinner
Whether to show a spinner at the beginning of the line. To make the spinner spin, you'll need to call
cli_progress_update()
regularly.- left
Label to show on the left. It interferes with the
center
label, only at most one of them can be present.- center
Label to show at the center. It interferes with the
left
andright
labels.- right
Label to show on the right. It interferes with the
center
label, only at most one of them can be present.- x
Vector that will be collapsed by cli.
- style
Style to apply to the vector. It is used as a theme on a
span
element that is created for the vector. You can setvec-sep
andvec-last
to modify the separator and the last separator.
Details
n <- "boo"
cli_abort(c(
"{.var n} must be a numeric vector",
"x" = "You've supplied a {.cls {class(n)}} vector."
))
#> Error: #> ! `n` must be a numeric vector #> ✖ You've supplied a <character> vector. #> Run `rlang::last_error()` to see where the error occurred.
len <- 26
idx <- 100
cli_abort(c(
"Must index an existing element:",
"i" = "There {?is/are} {len} element{?s}.",
"x" = "You've tried to subset element {idx}."
))
#> Error: #> ! Must index an existing element: #> ℹ There are 26 elements. #> ✖ You've tried to subset element 100. #> Run `rlang::last_error()` to see where the error occurred.
See also
These functions support inline markup.
Other functions supporting inline markup:
cli_alert()
,
cli_blockquote()
,
cli_bullets_raw()
,
cli_bullets()
,
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_update()
,
cli_status()
,
cli_text()
,
cli_ul()
,
format_error()
,
format_inline()