1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/format.R
\name{cli_vec}
\alias{cli_vec}
\title{Add custom cli style to a vector}
\usage{
cli_vec(x, style = list())
}
\arguments{
\item{x}{Vector that will be collapsed by cli.}
\item{style}{Style to apply to the vector. It is used as a theme on
a \code{span} element that is created for the vector. You can set \code{vec-sep}
and \code{vec-last} to modify the separator and the last separator.}
}
\description{
Add custom cli style to a vector
}
\details{
You can use this function to change the default parameters of
collapsing the vector into a string, see an example below.
The style is added as an attribute, so operations that remove
attributes will remove the style as well.
\subsection{Custom collapsing separator}{
\if{html}{\out{<div class="sourceCode r">}}\preformatted{v <- cli_vec(
c("foo", "bar", "foobar"),
style = list("vec-sep" = " & ", "vec-last" = " & ")
)
cli_text("My list: \{v\}.")
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> My list: foo & bar & foobar.
</pre></div>
}}
}
\subsection{Custom truncation}{
\if{html}{\out{<div class="sourceCode r">}}\preformatted{x <- cli_vec(names(mtcars), list("vec-trunc" = 3))
cli_text("Column names: \{x\}.")
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Column names: mpg, cyl, disp, …, gear, and carb.
</pre></div>
}}
}
}
\seealso{
\code{\link[=cli_format]{cli_format()}}
}
|