Parses cli inline markup and glue substitutions in
text without evaluating the embedded R expressions, returning the
symbol names referenced inside {...} interpolation blocks via
base::all.vars().
Arguments
- text
Character vector of cli format strings.
- functions
Logical scalar passed to
base::all.vars(): whether to include function names in addition to variable names. Defaults toTRUE.- unique
Logical scalar passed to
base::all.vars(): whether to deduplicate extracted symbol names. Defaults toTRUE.
Details
Static analysis tools (such as lintr::object_usage_linter()) can use
cli_extract_vars() to discover variables and functions referenced in
cli calls. Malformed cli strings or R expressions signal an error of
class "cli_error" (with subclasses "cli_glue_error",
"cli_style_error", "cli_parse_error", and
"cli_pluralization_error"), so static analysis callers should wrap
cli_extract_vars() in base::tryCatch().
If text is a named character vector (for example, as passed to
cli_dl(), cli_li(), cli_bullets(), or cli_abort()), both
names(text) and text are inspected.