cli_vec: Add custom cli style to a vector

Description Usage Arguments Details See Also Examples

View source: R/format.R

Description

Add custom cli style to a vector

Usage

1
cli_vec(x, style = list())

Arguments

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 set vec_sep and vec_last to modify the sep and last arguments of glue::glue_collapse(). See an example below.

Details

You can use this function to change the default parameters of glue::glue_collapse(), see an example below.

The style is added as an attribute, so operations that remove attributes will remove the style as well.

See Also

cli_format()

Examples

1
2
3
4
5
6
7
8
9
v <- cli_vec(
  c("foo", "bar", "foobar"),
  style = list(vec_sep = " & ", vec_last = " & ")
)
cli_text("My list: {v}.")

# custom truncation
x <- cli_vec(names(mtcars), list(vec_trunc = 3))
cli_text("Column names: {x}.")

RonMobile/cli documentation built on Dec. 18, 2021, 11 a.m.