}}
\subsection{Vectorization}{
Note that it is not possible to add link text to a vector of URLs. E.g.
this will create a list of three URLs, all clickable:
\if{html}{\out{
But it is not possible to use a different link text for them.
}}
}
\subsection{What if hyperlinks are not available?}{
If ANSI hyperlinks are not available, then the link text for of these
styles outputs both the link text and the URL in a (hopefully) helpful
way. See examples below.
}
}
\section{URLs}{
There are two cli styles to link to generic URLs. \code{.url} does not
allow custom link text, but \verb{\\href} does.
\if{html}{\out{
}}\preformatted{cli_text(
"See the cli homepage at \{.url https://cli.r-lib.org\} for details."
)
}\if{html}{\out{
}}
\subsection{Without hyperlink support}{
This is how these links look without hyperlink support:
\if{html}{\out{
}}\preformatted{local(\{
withr::local_options(cli.hyperlink = FALSE)
cli_text(
"See the cli homepage at \{.url https://cli.r-lib.org\} for details."
)
cli_text(
"See the \{.href [cli homepage](https://cli.r-lib.org)\} for details."
)
\})
}\if{html}{\out{
}}\if{html}{\out{
#> See the cli homepage at <https://cli.r-lib.org> for details.
#> See the cli homepage (<https://cli.r-lib.org>) for details.
}}
}
\subsection{URL encoding}{
Note that cli does not encode the url, so you might need to call
\code{utils::URLencode()} on it, especially, if it is substituted in
via \code{{}}.
\if{html}{\out{
}}\preformatted{weirdurl <- utils::URLencode("https://example.com/has some spaces")
cli_text("See more at \{.url \{weirdurl\}\}.")
}\if{html}{\out{
}}
}
}
\section{Files}{
The \code{.file} style now automatically creates a \verb{file:} hyperlink.
Because \verb{file:} hyperlinks must contain an absolute path, cli tries to
convert relative paths, and paths starting with \code{~} to aboslute path.
\if{html}{\out{
}}\preformatted{cli_text("... edit your \{.file ~/.Rprofile\} file.\}")
}\if{html}{\out{
}}
\subsection{Link text}{
\code{.file} cannot use a custom link text. If you custom link text, then
you can use \code{.href} with a \verb{file:} URL.
\if{html}{\out{
}}\preformatted{prof <- path.expand("~/.Rprofile")
cli_text("... edit your \{.href [R profile](file://\{prof\})\}.")
}\if{html}{\out{
}}
}
\subsection{Line and column numbers}{
You may add a line number to a file name, separated by \code{:}. Handlers
typically place the cursor at that line after opening the file.
You may also add a column number, after the line number, separated by
another \code{:}.
\if{html}{\out{
}}\preformatted{cli_text("... see line 5 in \{.file ~/.Rprofile:5\}.")
}\if{html}{\out{
}}
}
\subsection{Default handler}{
In RStudio \verb{file:} URLs open within RStudio. If you click on a file
link outside of RStudio, typically the operating system is consulted
for the application to open it.
}
\subsection{Without hyperlink support}{
One issue with using \code{.href} file files is that it does not look great
if hyperlinks are not available. This will be improved in the future:
\if{html}{\out{
#> ... edit your R profile (<file:///Users/gaborcsardi/.Rprofile>).
}}
}
}
\section{Links to the manual}{
\code{.fun} automatically creates links to the manual page of the function,
provided the function name is in the \code{packagename::functionname} form:
\if{html}{\out{
}}\preformatted{cli::cli_text("... see \{.fun stats::lm\} to learn more.")
}\if{html}{\out{
}}
}
}
\section{Click to run code}{
RStudio also supports a special link type that runs R code in the
current R session upon clicking.
You can create these links with \code{.run}:
\if{html}{\out{
}}\preformatted{cli::cli_text("Run \{.run testthat::snapshot_review()\} to review")
}\if{html}{\out{
}}
\subsection{Link text}{
Sometimes you want to show a slightly different expression in the link,
than the one that is evaluated. E.g. the evaluated expression probably
needs to qualify packages with \code{::}, but you might not want to show this:
\if{html}{\out{
}}\preformatted{cli::cli_text(
"Run \{.run [snapshot_review()](testthat::snapshot_review())\} to review"
)
}\if{html}{\out{
}}
}
\subsection{Security considerations}{
To make \code{.run} hyperlinks more secure, RStudio will not run code
\itemize{
\item that is not in the \code{pkg::fun(args)} form,
\item if \code{args} contains \code{(}, \verb{)} or \verb{;},
\item if it calls a core package (base, stats, etc.),
\item if it calls a package that is not loaded, and it is not one of
testthat, devtools, usethis, rlang, pkgload, or pkgdown which are explicitly allowed.
}
When RStudio does not run a \code{.run} hyperlink, then it shows the code
and the user can copy and paste it to the console, if they consider
it safe to run.
Note that depending on your version of RStudio, the behavior can change.
}
}
cli/man/format_inline.Rd 0000644 0001762 0000144 00000003364 14500305721 014714 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{format_inline}
\alias{format_inline}
\title{Format and returns a line of text}
\usage{
format_inline(
...,
.envir = parent.frame(),
collapse = TRUE,
keep_whitespace = TRUE
)
}
\arguments{
\item{...}{Passed to \code{\link[=cli_text]{cli_text()}}.}
\item{.envir}{Environment to evaluate the expressions in.}
\item{collapse}{Whether to collapse the result if it has multiple
lines, e.g. because of \verb{\\f} characters.}
\item{keep_whitespace}{Whether to keep all whitepace (spaces, newlines
and form feeds) as is in the input.}
}
\value{
Character scalar, the formatted string.
}
\description{
You can use this function to format a line of cli text, without emitting
it to the screen. It uses \code{\link[=cli_text]{cli_text()}} internally.
}
\details{
\code{format_inline()} performs no width-wrapping.
}
\examples{
format_inline("A message for {.emph later}, thanks {.fn format_inline}.")
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()}
}
\concept{functions supporting inline markup}
cli/man/ansi_simplify.Rd 0000644 0001762 0000144 00000001015 14200445676 014736 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_simplify}
\alias{ansi_simplify}
\title{Simplify ANSI styling tags}
\usage{
ansi_simplify(x, csi = c("keep", "drop"))
}
\arguments{
\item{x}{Input string}
\item{csi}{What to do with non-SGR ANSI sequences, either \code{"keep"},
or \code{"drop"} them.}
}
\value{
Simplified \code{cli_ansi_string} vector.
}
\description{
It creates an equivalent, but possibly shorter ANSI styled string, by
removing duplicate and empty tags.
}
cli/man/cli_vec.Rd 0000644 0001762 0000144 00000003516 14332664317 013505 0 ustar ligges users % 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{
#> Column names: mpg, cyl, disp, …, gear, and carb.
}}
}
}
\seealso{
\code{\link[=cli_format]{cli_format()}}
}
cli/man/pluralization.Rd 0000644 0001762 0000144 00000021340 14232501151 014752 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pluralize.R
\name{pluralization}
\alias{pluralization}
\title{About cli pluralization}
\description{
About cli pluralization
}
\section{Introduction}{
cli has tools to create messages that are printed correctly in singular
and plural forms. This usually requires minimal extra work, and
increases the quality of the messages greatly. In this document we first
show some pluralization examples that you can use as guidelines.
Hopefully these are intuitive enough, so that they can be used without
knowing the exact cli pluralization rules.
If you need pluralization without the semantic cli functions, see the
\code{pluralize()} function.
}
\section{Examples}{
\subsection{Pluralization markup}{
In the simplest case the message contains a single \code{{}} glue
substitution, which specifies the quantity that is used to select
between the singular and plural forms. Pluralization uses markup that is
similar to glue, but uses the \verb{\{?} and \verb{\}} delimiters:
\if{html}{\out{
}}\preformatted{#> Found 2 files.
}\if{html}{\out{
}}
Here the value of \code{nfile} is used to decide whether the singular or
plural form of \code{file} is used. This is the most common case for English
messages.
}
\subsection{Irregular plurals}{
If the plural form is more difficult than a simple \code{s} suffix, then the
singular and plural forms can be given, separated with a forward slash:
\if{html}{\out{
}}\preformatted{#> Found 5 directories.
}\if{html}{\out{
}}
}
\subsection{Use \code{"no"} instead of zero}{
For readability, it is better to use the \code{no()} helper function to
include a count in a message. \code{no()} prints the word \code{"no"} if the count
is zero, and prints the numeric count otherwise:
\if{html}{\out{
}}\preformatted{#> Found 2 files.
}\if{html}{\out{
}}
}
\subsection{Use the length of character vectors}{
With the auto-collapsing feature of cli it is easy to include a list of
objects in a message. When cli interprets a character vector as a
pluralization quantity, it takes the length of the vector:
\if{html}{\out{
}}\preformatted{pkgs <- "pkg1"
cli_text("Will remove the \{.pkg \{pkgs\}\} package\{?s\}.")
}\if{html}{\out{
}}
\if{html}{\out{
}}\preformatted{#> Will remove the pkg1 package.
}\if{html}{\out{
}}\preformatted{#> Will remove the pkg1, pkg2, and pkg3 packages.
}\if{html}{\out{
}}
Note that the length is only used for non-numeric vectors (when
\code{is.numeric(x)} return \code{FALSE}). If you want to use the length of a
numeric vector, convert it to character via \code{as.character()}.
You can combine collapsed vectors with \code{"no"}, like this:
\if{html}{\out{
}}\preformatted{#> Will remove the pkg1, pkg2, and pkg3 packages.
}\if{html}{\out{
}}
When the pluralization markup contains three alternatives, like above,
the first one is used for zero, the second for one, and the third one
for larger quantities.
}
\subsection{Choosing the right quantity}{
When the text contains multiple glue \code{{}} substitutions, the one right
before the pluralization markup is used. For example:
\if{html}{\out{
}}\preformatted{#> Found 3 files and 1 directory
}\if{html}{\out{
}}
This is sometimes not the the correct one. You can explicitly specify
the correct quantity using the \code{qty()} function. This sets that quantity
without printing anything:
\if{html}{\out{
}}\preformatted{#> 3/10 files need updates
}\if{html}{\out{
}}
Note that if the message only contains a single \code{{}} substitution, then
this may appear before or after the pluralization markup. If the message
contains multiple \code{{}} substitutions \emph{after} pluralization markup, an
error is thrown.
Similarly, if the message contains no \code{{}} substitutions at all, but has
pluralization markup, an error is thrown.
}
}
\section{Rules}{
The exact rules of cli pluralization. There are two sets of rules. The
first set specifies how a quantity is associated with a \verb{\{?\}}
pluralization markup. The second set describes how the \verb{\{?\}} is parsed
and interpreted.
\subsection{Quantities}{
\enumerate{
\item \code{{}} substitutions define quantities. If the value of a \code{{}}
substitution is numeric (when \code{is.numeric(x)} holds), then it has to
have length one to define a quantity. This is only enforced if the
\code{{}} substitution is used for pluralization. The quantity is defined
as the value of \code{{}} then, rounded with \code{as.integer()}. If the value
of \code{{}} is not numeric, then its quantity is defined as its length.
\item If a message has \verb{\{?\}} markup but no \code{{}} substitution, an error is
thrown.
\item If a message has exactly one \code{{}} substitution, its value is used as
the pluralization quantity for all \verb{\{?\}} markup in the message.
\item If a message has multiple \code{{}} substitutions, then for each \verb{\{?\}}
markup cli uses the quantity of the \code{{}} substitution that precedes
it.
\item If a message has multiple \code{{}} substitutions and has pluralization
markup without a preceding \code{{}} substitution, an error is thrown.
}
}
\subsection{Pluralization markup}{
\enumerate{
\item Pluralization markup starts with \verb{\{?} and ends with \verb{\}}. It may not
contain \verb{\{} and \verb{\}} characters, so it may not contain \code{{}}
substitutions either.
\item Alternative words or suffixes are separated by \code{/}.
\item If there is a single alternative, then \emph{nothing} is used if
\code{quantity == 1} and this single alternative is used if
\code{quantity != 1}.
\item If there are two alternatives, the first one is used for
\code{quantity == 1}, the second one for \code{quantity != 1} (including
`\code{quantity == 0}).
\item If there are three alternatives, the first one is used for
\code{quantity == 0}, the second one for \code{quantity == 1}, and the third
one otherwise.
}
}
}
\seealso{
Other pluralization:
\code{\link{no}()},
\code{\link{pluralize}()}
}
\concept{pluralization}
cli/man/num_ansi_colors.Rd 0000644 0001762 0000144 00000013204 14521175065 015263 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/num-ansi-colors.R
\name{num_ansi_colors}
\alias{num_ansi_colors}
\alias{detect_tty_colors}
\title{Detect the number of ANSI colors to use}
\usage{
num_ansi_colors(stream = "auto")
detect_tty_colors()
}
\arguments{
\item{stream}{The stream that will be used for output, an R connection
object. It can also be a string, one of \code{"auto"}, \code{"message"},
\code{"stdout"}, \code{"stderr"}. \code{"auto"} will select \code{stdout()} if the session is
interactive and there are no sinks, otherwise it will select \code{stderr()}.}
}
\value{
Integer, the number of ANSI colors the current R session
supports for \code{stream}.
}
\description{
Certain Unix and Windows terminals, and also certain R GUIs, e.g.
RStudio, support styling terminal output using special control
sequences (ANSI sequences).
\code{num_ansi_colors()} detects if the current R session supports ANSI
sequences, and if it does how many colors are supported.
}
\details{
The detection mechanism is quite involved and it is designed to work
out of the box on most systems. If it does not work on your system,
please report a bug. Setting options and environment variables to turn
on ANSI support is error prone, because they are inherited in other
environments, e.g. knitr, that might not have ANSI support.
If you want to \emph{turn off} ANSI colors, set the \code{NO_COLOR} environment
variable to a non-empty value.
The exact detection mechanism is as follows:
\enumerate{
\item If the \code{cli.num_colors} options is set, that is returned.
\item If the \code{R_CLI_NUM_COLORS} environment variable is set to a
non-empty value, then it is used.
\item If the \code{crayon.enabled} option is set to \code{FALSE}, 1L is returned.
(This is for compatibility with code that uses the crayon package.)
\item If the \code{crayon.enabled} option is set to \code{TRUE} and the
\code{crayon.colors} option is not set, then the value of the
\code{cli.default_num_colors} option, or if it is unset, then 8L is
returned.
\item If the \code{crayon.enabled} option is set to \code{TRUE} and the
\code{crayon.colors} option is also set, then the latter is returned.
(This is for compatibility with code that uses the crayon package.)
\item If the \code{NO_COLOR} environment variable is set, then 1L is returned.
\item If we are in knitr, then 1L is returned, to turn off colors in
\code{.Rmd} chunks.
\item If \code{stream} is \code{"auto"} (the default) and there is an active
sink (either for \code{"output"} or \code{"message"}), then we return 1L.
(In theory we would only need to check the stream that will be
be actually used, but there is no easy way to tell that.)
\item If \code{stream} is not \code{"auto"}, but it is \code{stderr()} and there is an
active sink for it, then 1L is returned.
(If a sink is active for "output", then R changes the \code{stdout()}
stream, so this check is not needed.)
\item If the \code{cli.default_num_colors} option is set, then we use that.
\item If R is running inside RGui on Windows, or R.app on macOS, then we
return 1L.
\item If R is running inside RStudio, with color support, then the
appropriate number of colors is returned, usually 256L.
\item If R is running on Windows, inside an Emacs version that is recent
enough to support ANSI colors, then the value of the
\code{cli.default_num_colors} option, or if unset 8L is returned.
(On Windows, Emacs has \code{isatty(stdout()) == FALSE}, so we need to
check for this here before dealing with terminals.)
\item If \code{stream} is not the standard output or standard error in a
terminal, then 1L is returned.
\item Otherwise we use and cache the result of the terminal color
detection (see below).
}
The terminal color detection algorithm:
\enumerate{
\item If the \code{COLORTERM} environment variable is set to \code{truecolor} or
\verb{24bit}, then we return 16 million colors.
\item If the \code{COLORTERM} environment variable is set to anything else,
then we return the value of the \code{cli.num_default_colors} option,
8L if unset.
\item If R is running on Unix, inside an Emacs version that is recent
enough to support ANSI colors, then the value of the
\code{cli.default_num_colors} option is returned, or 8L if unset.
\item If we are on Windows in an RStudio terminal, then apparently
we only have eight colors, but the \code{cli.default_num_colors} option
can be used to override this.
\item If we are in a recent enough Windows 10 terminal, then there
is either true color (from build 14931) or 256 color (from
build 10586) support. You can also use the \code{cli.default_num_colors}
option to override these.
\item If we are on Windows, under ConEmu or cmder, or ANSICON is loaded,
then the value of \code{cli.default_num_colors}, or 8L if unset, is
returned.
\item Otherwise if we are on Windows, return 1L.
\item Otherwise we are on Unix and try to run \verb{tput colors} to determine
the number of colors. If this succeeds, we return its return value.
If the \code{TERM} environment variable is \code{xterm} and \code{tput}
returned 8L, we return 256L, because xterm compatible terminals
tend to support 256 colors
(\url{https://github.com/r-lib/crayon/issues/17})
You can override this with the \code{cli.default_num_colors} option.
\item If \code{TERM} is set to \code{dumb}, we return 1L.
\item If \code{TERM} starts with \code{screen}, \code{xterm}, or \code{vt100}, we return 8L.
\item If \code{TERM} contains \code{color}, \code{ansi}, \code{cygwin} or \code{linux}, we return 8L.
\item Otherwise we return 1L.
}
}
\examples{
num_ansi_colors()
}
\seealso{
Other ANSI styling:
\code{\link{ansi-styles}},
\code{\link{combine_ansi_styles}()},
\code{\link{make_ansi_style}()}
}
\concept{ANSI styling}
cli/man/ansi_regex.Rd 0000644 0001762 0000144 00000001121 14521175065 014210 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_regex}
\alias{ansi_regex}
\title{Perl compatible regular expression that matches ANSI escape
sequences}
\usage{
ansi_regex()
}
\value{
String scalar, the regular expression.
}
\description{
Don't forget to use \code{perl = TRUE} when using this with \code{\link[=grepl]{grepl()}} and
friends.
}
\seealso{
Other low level ANSI functions:
\code{\link{ansi_has_any}()},
\code{\link{ansi_hide_cursor}()},
\code{\link{ansi_string}()},
\code{\link{ansi_strip}()}
}
\concept{low level ANSI functions}
cli/man/utf8_substr.Rd 0000644 0001762 0000144 00000002007 14143453131 014351 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utf8.R
\name{utf8_substr}
\alias{utf8_substr}
\title{Substring of an UTF-8 string}
\usage{
utf8_substr(x, start, stop)
}
\arguments{
\item{x}{Character vector.}
\item{start}{Starting index or indices, recycled to match the length
of \code{x}.}
\item{stop}{Ending index or indices, recycled to match the length of
\code{x}.}
}
\value{
Character vector of the same length as \code{x}, containing
the requested substrings.
}
\description{
This function uses grapheme clusters instead of Unicode code points in
UTF-8 strings.
}
\examples{
# Five grapheme clusters, select the middle three
str <- paste0(
"\U0001f477\U0001f3ff\u200d\u2640\ufe0f",
"\U0001f477\U0001f3ff",
"\U0001f477\u200d\u2640\ufe0f",
"\U0001f477\U0001f3fb",
"\U0001f477\U0001f3ff")
cat(str)
str24 <- utf8_substr(str, 2, 4)
cat(str24)
}
\seealso{
Other UTF-8 string manipulation:
\code{\link{utf8_graphemes}()},
\code{\link{utf8_nchar}()}
}
\concept{UTF-8 string manipulation}
cli/man/make_spinner.Rd 0000644 0001762 0000144 00000006564 14300734360 014551 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spinner.R
\name{make_spinner}
\alias{make_spinner}
\title{Create a spinner}
\usage{
make_spinner(
which = NULL,
stream = "auto",
template = "{spin}",
static = c("dots", "print", "print_line", "silent")
)
}
\arguments{
\item{which}{The name of the chosen spinner. If \code{NULL}, then the default
is used, which can be customized via the \code{cli.spinner_unicode},
\code{cli.spinner_ascii} and \code{cli.spinner} options. (The latter applies to
both Unicode and ASCII displays. These options can be set to the name
of a built-in spinner, or to a list that has an entry called \code{frames},
a character vector of frames.}
\item{stream}{The stream to use for the spinner. Typically this is
standard error, or maybe the standard output stream.
It can also be a string, one of \code{"auto"}, \code{"message"}, \code{"stdout"},
\code{"stderr"}. \code{"auto"} will select \code{stdout()} if the session is
interactive and there are no sinks, otherwise it will select
\code{stderr()}.}
\item{template}{A template string, that will contain the spinner. The
spinner itself will be substituted for \code{{spin}}. See example below.}
\item{static}{What to do if the terminal does not support dynamic
displays:
\itemize{
\item \code{"dots"}: show a dot for each \verb{$spin()} call.
\item \code{"print"}: just print the frames of the spinner, one after another.
\item \code{"print_line"}: print the frames of the spinner, each on its own line.
\item \code{"silent"} do not print anything, just the \code{template}.
}}
}
\value{
A \code{cli_spinner} object, which is a list of functions. See
its methods below.
\code{cli_spinner} methods:
\itemize{
\item \verb{$spin()}: output the next frame of the spinner.
\item \verb{$finish()}: terminate the spinner. Depending on terminal capabilities
this removes the spinner from the screen. Spinners can be reused,
you can start calling the \verb{$spin()} method again.
}
All methods return the spinner object itself, invisibly.
The spinner is automatically throttled to its ideal update frequency.
}
\description{
Create a spinner
}
\section{Examples}{
\subsection{Default spinner}{
\if{html}{\out{
}}
\if{html}{\figure{make-spinner-custom.svg}}
}
}
\seealso{
Other spinners:
\code{\link{demo_spinners}()},
\code{\link{get_spinner}()},
\code{\link{list_spinners}()}
}
\concept{spinners}
cli/man/cli_progress_along.Rd 0000644 0001762 0000144 00000007616 14500305721 015745 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-along.R
\name{cli_progress_along}
\alias{cli_progress_along}
\title{Add a progress bar to a mapping function or for loop}
\usage{
cli_progress_along(
x,
name = NULL,
total = length(x),
...,
.envir = parent.frame()
)
}
\arguments{
\item{x}{Sequence to add the progress bar to.}
\item{name}{Name of the progress bar, a label, passed to
\code{\link[=cli_progress_bar]{cli_progress_bar()}}.}
\item{total}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.}
\item{...}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.}
\item{.envir}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.}
}
\value{
An index vector from 1 to \code{length(x)} that triggers progress
updates as you iterate over it.
}
\description{
Note that this function is currently experimental!
Use \code{cli_progress_along()} in a mapping function or in a for loop, to add a
progress bar. It uses \code{\link[=cli_progress_bar]{cli_progress_bar()}} internally.
}
\details{
\subsection{\code{for} loop}{
A \code{for} loop with \code{cli_progress_along()} looks like this:
\if{html}{\out{
}}\preformatted{for (i in cli_progress_along(seq)) \{
...
\}
}\if{html}{\out{
}}
A complete example:
\if{html}{\out{
}}\preformatted{clifun <- function() \{
for (i in cli_progress_along(1:100, "Downloading")) \{
Sys.sleep(4/100)
\}
\}
clifun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-along-1.svg}}
}
\subsection{\code{lapply()} and other mapping functions}{
They will look like this:
\if{html}{\out{
}}
\if{html}{\figure{progress-along-2.svg}}
}
\subsection{Custom format string}{
\if{html}{\out{
}}\preformatted{clifun <- function() \{
for (i in cli_progress_along(1:100,
format = "Downloading data file \{cli::pb_current\}")) \{
Sys.sleep(4/100)
\}
\}
clifun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-along-3.svg}}
}
\subsection{Breaking out of loops}{
Note that if you use \code{break} in the \code{for} loop, you probably want to
terminate the progress bar explicitly when breaking out of the loop,
or right after the loop:
\if{html}{\out{
}}\preformatted{for (i in cli_progress_along(seq)) \{
...
if (cond) cli_progress_done() && break
...
\}
}\if{html}{\out{
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
\code{\link[=cli_progress_bar]{cli_progress_bar()}} and the traditional progress bar API.
Other progress bar functions:
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()},
\code{\link{progress-variables}}
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
\concept{progress bar functions}
cli/man/console_width.Rd 0000644 0001762 0000144 00000002710 14143453131 014723 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/width.R
\name{console_width}
\alias{console_width}
\title{Determine the width of the console}
\usage{
console_width()
}
\value{
Integer scalar, the console with, in number of characters.
}
\description{
It uses the \code{cli.width} option, if set. Otherwise it tries to
determine the size of the terminal or console window.
}
\details{
These are the exact rules:
\itemize{
\item If the \code{cli.width} option is set to a positive integer, it is used.
\item If the \code{cli.width} option is set, but it is not a positive integer,
and error is thrown.
}
Then we try to determine the size of the terminal or console window:
\itemize{
\item If we are not in RStudio, or we are in an RStudio terminal,
then we try to use the \code{tty_size()} function to query the
terminal size. This might fail if R is not running in a terminal,
but failures are ignored.
\item If we are in the RStudio build pane, then the \code{RSTUDIO_CONSOLE_WIDTH}
environment variable is used. If the build pane is resized, then this
environment variable is not accurate any more, and the output might
get garbled.
\item We are \emph{not} using the \code{RSTUDIO_CONSOLE_WIDTH} environment variable
if we are in the RStudio console.
}
If we cannot determine the size of the terminal or console window, then
we use the \code{width} option. If the \code{width} option is not set, then
we return 80L.
}
\examples{
console_width()
}
cli/man/progress-utils.Rd 0000644 0001762 0000144 00000002113 14500305721 015057 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-utils.R
\name{cli_progress_num}
\alias{cli_progress_num}
\alias{cli_progress_cleanup}
\title{Progress bar utility functions.}
\usage{
cli_progress_num()
cli_progress_cleanup()
}
\value{
\code{cli_progress_num()} returns an integer scalar.
`cli_progress_cleanup() does not return anything.
}
\description{
Progress bar utility functions.
}
\details{
\code{cli_progress_num()} returns the number of currently
active progress bars. (These do not currently include the progress
bars created in C/C++ code.)
\code{cli_progress_cleanup()} terminates all active progress bars.
(It currently ignores progress bars created in the C/C++ code.)
}
\seealso{
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()},
\code{\link{progress-variables}}
}
\concept{progress bar functions}
cli/man/progress-c.Rd 0000644 0001762 0000144 00000015564 14262015555 014167 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/docs.R
\name{progress-c}
\alias{progress-c}
\title{The cli progress C API}
\description{
The cli progress C API
}
\section{The cli progress C API}{
\subsection{\code{CLI_SHOULD_TICK}}{
A macro that evaluates to (int) 1 if a cli progress bar update is due,
and to (int) 0 otherwise. If the timer hasn't been initialized in this
compilation unit yet, then it is always 0. To initialize the timer,
call \code{cli_progress_init_timer()} or create a progress bar with
\code{cli_progress_bar()}.
}
\subsection{\code{cli_progress_add()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_add(SEXP bar, double inc);
}\if{html}{\out{
}}
Add a number of progress units to the progress bar. It will also
trigger an update if an update is due.
\itemize{
\item \code{bar}: progress bar object.
\item \code{inc}: progress increment.
}
}
\subsection{\code{cli_progress_bar()}}{
\if{html}{\out{
}}
Create a new progress bar object. The returned progress bar object
must be \code{PROTECT()}-ed.
\itemize{
\item \code{total}: Total number of progress units. Use \code{NA_REAL} if it is not
known.
\item \code{config}: R named list object of additional parameters. May be \code{NULL}
(the C \verb{NULL~) or }R_NilValue\verb{(the R}NULL`) for the defaults.
}
\code{config} may contain the following entries:
\itemize{
\item \code{name}: progress bar name.
\item \code{status}: (initial) progress bar status.
\item \code{type}: progress bar type.
\item \code{total}: total number of progress units.
\item \code{show_after}: show the progress bar after the specified number of
seconds. This overrides the global \code{show_after} option.
\item \code{format}: format string, must be specified for custom progress bars.
\item \code{format_done}: format string for successful termination.
\item \code{format_failed}: format string for unsuccessful termination.
\item \code{clear}: whether to remove the progress bar from the screen after
termination.
\item \code{auto_terminate}: whether to terminate the progress bar when the
number of current units equals the number of total progress units.
}
\subsection{Example}{
\if{html}{\out{
}}\preformatted{#include
SEXP progress_test1() \{
int i;
SEXP bar = PROTECT(cli_progress_bar(1000, NULL));
for (i = 0; i < 1000; i++) \{
cli_progress_sleep(0, 4 * 1000 * 1000);
if (CLI_SHOULD_TICK) cli_progress_set(bar, i);
\}
cli_progress_done(bar);
UNPROTECT(1);
return Rf_ScalarInteger(i);
\}
}\if{html}{\out{
}}
Returns the number of currently active progress bars.
}
\subsection{\code{cli_progress_set()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set(SEXP bar, double set);
}\if{html}{\out{
}}
Set the progress bar to the specified number of progress units.
\itemize{
\item \code{bar}: progress bar object.
\item \code{set}: number of current progress progress units.
}
}
\subsection{\code{cli_progress_set_clear()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set_clear(SEXP bar, int clear);
}\if{html}{\out{
}}
Set whether to remove the progress bar from the screen. You can call
this any time before \code{cli_progress_done()} is called.
\itemize{
\item \code{bar}: progress bar object.
\item \code{clear}: whether to remove the progress bar from the screen, zero or
one.
}
}
\subsection{\code{cli_progress_set_format()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set_format(SEXP bar, const char *format, ...);
}\if{html}{\out{
}}
Set a custom format string for the progress bar. This call does not
try to update the progress bar. If you want to request an update,
call \code{cli_progress_add()}, \code{cli_progress_set()} or
\code{cli_progress_update()}.
\itemize{
\item \code{bar}: progress bar object.
\item \code{format}: format string.
\item \code{...}: values to substitute into \code{format}.
}
\code{format} and \code{...} are passed to \code{vsnprintf()} to create a format
string.
Format strings may contain glue substitutions, referring to
\href{https://cli.r-lib.org/dev/reference/progress-variables.html}{progress variables}, pluralization, and cli
styling.
}
\subsection{\code{cli_progress_set_name()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set_name(SEXP bar, const char *name);
}\if{html}{\out{
}}
Set the name of the progress bar.
\itemize{
\item \code{bar}; progress bar object.
\item \code{name}: progress bar name.
}
}
\subsection{\code{cli_progress_set_status()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set_status(SEXP bar, const char *status);
}\if{html}{\out{
}}
Set the status of the progress bar.
\itemize{
\item \code{bar}: progress bar object.
\item \code{status }: progress bar status.
}
}
\subsection{\code{cli_progress_set_type()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_set_type(SEXP bar, const char *type);
}\if{html}{\out{
}}
Set the progress bar type. Call this function right after creating
the progress bar with \code{cli_progress_bar()}. Otherwise the behavior is
undefined.
\itemize{
\item \code{bar}: progress bar object.
\item \code{type}: progress bar type. Possible progress bar types:
\code{iterator}, \code{tasks}, \code{download} and \code{custom}.
}
}
\subsection{\code{cli_progress_update()}}{
\if{html}{\out{
}}\preformatted{void cli_progress_update(SEXP bar, double set, double inc, int force);
}\if{html}{\out{
}}
Update the progress bar. Unlike the simpler \code{cli_progress_add()} and
\code{cli_progress_set()} function, it can force an update if \code{force} is
set to 1.
\itemize{
\item \code{bar}: progress bar object.
\item \code{set}: the number of current progress units. It is ignored if
negative.
\item \code{inc}: increment to add to the current number of progress units.
It is ignored if \code{set} is not negative.
\item \code{force}: whether to force an update, even if no update is due.
}
To force an update without changing the current number of progress units,
supply \code{set = -1}, \code{inc = 0} and \code{force = 1}.
}
}
cli/man/code_highlight.Rd 0000644 0001762 0000144 00000002144 14317007616 015032 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prettycode.R
\name{code_highlight}
\alias{code_highlight}
\title{Syntax highlight R code}
\usage{
code_highlight(code, code_theme = NULL, envir = NULL)
}
\arguments{
\item{code}{Character vector, each element is one line of code.}
\item{code_theme}{Theme see \code{\link[=code_theme_list]{code_theme_list()}}.}
\item{envir}{Environment to look up function calls for hyperlinks.
If \code{NULL}, then the global search path is used.}
}
\value{
Character vector, the highlighted code.
}
\description{
Syntax highlight R code
}
\details{
See \code{\link[=code_theme_list]{code_theme_list()}} for the default syntax highlighting theme and
how to change it.
If \code{code} does not parse, then it is returned unchanged and a
\code{cli_parse_failure} condition is thrown. Note that this is not an error,
and the condition is ignored, unless explicitly caught.
}
\examples{
code_highlight(deparse(ls))
cat(code_highlight(deparse(ls)), sep = "\n")
}
\seealso{
Other syntax highlighting:
\code{\link{code_theme_list}()}
}
\concept{syntax highlighting}
cli/man/cli_text.Rd 0000644 0001762 0000144 00000013723 14500305721 013701 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_text}
\alias{cli_text}
\title{CLI text}
\usage{
cli_text(..., .envir = parent.frame())
}
\arguments{
\item{...}{The text to show, in character vectors. They will be
concatenated into a single string. Newlines are \emph{not} preserved.}
\item{.envir}{Environment to evaluate the glue expressions in.}
}
\description{
Write some text to the screen. This function is most appropriate for
longer paragraphs. See \code{\link[=cli_alert]{cli_alert()}} for shorter status messages.
}
\details{
\subsection{Text wrapping}{
Text is wrapped to the console width, see \code{\link[=console_width]{console_width()}}.
\if{html}{\out{
#> Lorem ad ipsum veniam esse nisi deserunt duis. Qui incididunt elit
#> elit mollit sint nulla consectetur aute commodo do elit laboris minim
#> et. Laboris ipsum mollit voluptate et non do incididunt eiusmod. Anim
#> consectetur mollit laborum occaecat eiusmod excepteur. Ullamco non
#> tempor esse anim tempor magna non.
}}
}
\subsection{New lines}{
A \code{cli_text()} call always appends a newline character to the end.
\if{html}{\out{
}}
}
\subsection{Containers}{
You can use \code{cli_text()} within cli \link{containers}.
\if{html}{\out{
}}\preformatted{ul <- cli_ul()
cli_li("First item.")
cli_text("Still the \{.emph first\} item")
cli_li("Second item.")
cli_text("Still the \{.emph second\} item")
cli_end(ul)
}\if{html}{\out{
}}\if{html}{\out{
#> • First item.
#> Still the first item
#> • Second item.
#> Still the second item
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/unicode-width-workaround.Rd 0000644 0001762 0000144 00000002625 14143453131 017023 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/unicode.R
\name{unicode-width-workaround}
\alias{unicode-width-workaround}
\title{Working around the bad Unicode character widths}
\description{
R 3.6.2 and also the coming 3.6.3 and 4.0.0 versions use the Unicode 8
standard to calculate the display width of Unicode characters.
Unfortunately the widths of most emojis are incorrect in this standard,
and width 1 is reported instead of the correct 2 value.
}
\details{
cli implements a workaround for this. The package contains a table that
contains all Unicode ranges that have wide characters (display width 2).
On first use of one of the workaround wrappers (in \code{ansi_nchar()}, etc.)
we check what the current version of R thinks about the width of these
characters, and then create a regex that matches the ones that R
is wrong about (\code{re_bad_char_width}).
Then we use this regex to duplicate all of the problematic characters
in the input string to the wrapper function, before calling the real
string manipulation function (\code{nchar()}, \code{strwrap()}) etc. At end we
undo the duplication before we return the result.
This workaround is fine for \code{nchar()} and \code{strwrap()}, and consequently
\code{ansi_align()} and \code{ansi_strtrim()} as well.
The rest of the \verb{ansi_*()} functions work on characters, and do not
deal with character width.
}
\keyword{internal}
cli/man/cli_dl.Rd 0000644 0001762 0000144 00000006647 14500305721 013323 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_dl}
\alias{cli_dl}
\title{Definition list}
\usage{
cli_dl(
items = NULL,
labels = names(items),
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
}
\arguments{
\item{items}{Named character vector, or \code{NULL}. If not \code{NULL}, they
are used as list items.}
\item{labels}{Item labels. Defaults the names in \code{items}.}
\item{id}{Id of the list container. Can be used for closing it with
\code{\link[=cli_end]{cli_end()}} or in themes. If \code{NULL}, then an id is generated and
returned invisibly.}
\item{class}{Class of the list container. Can be used in themes.}
\item{.close}{Whether to close the list container if the \code{items} were
specified. If \code{FALSE} then new items can be added to the list.}
\item{.auto_close}{Whether to close the container, when the calling
function finishes (or \code{.envir} is removed, if specified).}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-close the container if \code{.auto_close} is \code{TRUE}.}
}
\value{
The id of the new container element, invisibly.
}
\description{
A definition list is a container, see \link{containers}.
}
\details{
\subsection{All items at once}{
\if{html}{\out{
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/has_keypress_support.Rd 0000644 0001762 0000144 00000001441 14331172227 016361 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/keypress.R
\name{has_keypress_support}
\alias{has_keypress_support}
\title{Check if the current platform/terminal supports reading
single keys.}
\usage{
has_keypress_support()
}
\value{
Whether there is support for waiting for individual
keypressses.
}
\description{
Check if the current platform/terminal supports reading
single keys.
}
\details{
Supported platforms:
\itemize{
\item Terminals in Windows and Unix.
\item RStudio terminal.
}
Not supported:
\itemize{
\item RStudio (if not in the RStudio terminal).
\item R.app on macOS.
\item Rgui on Windows.
\item Emacs ESS.
\item Others.
}
}
\examples{
has_keypress_support()
}
\seealso{
Other keypress function:
\code{\link{keypress}()}
}
\concept{keypress function}
cli/man/cli_progress_builtin_handlers.Rd 0000644 0001762 0000144 00000006554 14500305721 020173 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-server.R
\name{cli_progress_builtin_handlers}
\alias{cli_progress_builtin_handlers}
\title{cli progress handlers}
\usage{
cli_progress_builtin_handlers()
}
\value{
\code{cli_progress_builtin_handlers()} returns the names of the
currently supported progress handlers.
}
\description{
The progress handler(s) to use can be selected with global options.
}
\details{
There are three options that specify which handlers will be selected,
but most of the time you only need to use one of them. You can set these
options to a character vector, the names of the built-in cli handlers you
want to use:
\itemize{
\item If \code{cli.progress_handlers_only} is set, then these handlers are used,
without considering others and without checking if they are able to
handle a progress bar. This option is mainly intended for testing
purposes.
\item The handlers named in \code{cli.progress_handlers} are checked if they are
able to handle the progress bar, and from the ones that are, the first
one is selected. This is usually the option that the end use would want
to set.
\item The handlers named in \code{cli.progress_handlers_force} are always appended
to the ones selected via \code{cli.progress_handlers}. This option is useful
to add an additional handler, e.g. a logger that writes to a file.
}
}
\section{The built-in progress handlers}{
\subsection{\code{cli}}{
Use cli's internal status bar, the last line of the screen, to show the
progress bar. This handler is always able to handle all progress bars.
}
\subsection{\code{logger}}{
Log progress updates to the screen, with one line for each update and with
time stamps. This handler is always able to handle all progress bars.
}
\subsection{\code{progressr}}{
Use the progressr package to create
progress bars. This handler is always able to handle all progress bars.
(The progressr package needs to be installed.)
}
\subsection{\code{rstudio}}{
Use \href{https://posit.co/blog/rstudio-1-2-jobs/}{RStudio's job panel}
to show the progress bars. This handler is available at the RStudio console,
in recent versions of RStudio.
}
\subsection{\code{say}}{
Use the macOS \code{say} command to announce progress events in speech (type
\verb{man say} on a terminal for more info). Set the \code{cli.progress_say_frequency}
option to set the minimum delay between \code{say} invocations, the default is
three seconds. This handler is available on macOS, if the \code{say} command is
on the path.
The external command and its arguments can be configured with options:
\itemize{
\item \code{cli_progress_say_args}: command line arguments, e.g. you can use this
to select a voice on macOS,
\item \code{cli_progress_say_command}: external command to run,
\item \code{cli_progress_say_frequency}: wait at least this many seconds between
calling the external command.
}
}
\subsection{\code{shiny}}{
Use \href{https://shiny.rstudio.com/articles/progress.html}{shiny's progress bars}.
This handler is available if a shiny app is running.
}
}
\seealso{
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()},
\code{\link{progress-variables}}
}
\concept{progress bar functions}
cli/man/cli_li.Rd 0000644 0001762 0000144 00000005414 14500305721 013317 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_li}
\alias{cli_li}
\title{CLI list item(s)}
\usage{
cli_li(
items = NULL,
labels = names(items),
id = NULL,
class = NULL,
.auto_close = TRUE,
.envir = parent.frame()
)
}
\arguments{
\item{items}{Character vector of items, or \code{NULL}.}
\item{labels}{For definition lists the item labels.}
\item{id}{Id of the new container. Can be used for closing it with
\code{\link[=cli_end]{cli_end()}} or in themes. If \code{NULL}, then an id is generated and
returned invisibly.}
\item{class}{Class of the item container. Can be used in themes.}
\item{.auto_close}{Whether to close the container, when the calling
function finishes (or \code{.envir} is removed, if specified).}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-close the container if \code{.auto_close} is \code{TRUE}.}
}
\value{
The id of the new container element, invisibly.
}
\description{
A list item is a container, see \link{containers}.
}
\details{
\subsection{Nested lists}{
\if{html}{\out{
#> • one:
#> 1. a
#> 2. b
#> 3. c
#> • two:
#> • three
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/cli_progress_bar.Rd 0000644 0001762 0000144 00000031772 14500305721 015411 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-client.R
\name{cli_progress_bar}
\alias{cli_progress_bar}
\alias{__cli_update_due}
\alias{cli_tick_reset}
\alias{ccli_tick_reset}
\alias{ticking}
\alias{cli_progress_update}
\alias{cli_progress_done}
\title{cli progress bars}
\usage{
cli_progress_bar(
name = NULL,
status = NULL,
type = c("iterator", "tasks", "download", "custom"),
total = NA,
format = NULL,
format_done = NULL,
format_failed = NULL,
clear = getOption("cli.progress_clear", TRUE),
current = TRUE,
auto_terminate = type != "download",
extra = NULL,
.auto_close = TRUE,
.envir = parent.frame()
)
cli_progress_update(
inc = NULL,
set = NULL,
total = NULL,
status = NULL,
extra = NULL,
id = NULL,
force = FALSE,
.envir = parent.frame()
)
cli_progress_done(id = NULL, .envir = parent.frame(), result = "done")
}
\arguments{
\item{name}{This is typically used as a label, and should be short,
at most 20 characters.}
\item{status}{New status string of the progress bar, if not \code{NULL}.}
\item{type}{Type of the progress bar. It is used to select a default
display if \code{format} is not specified. Currently supported types:
\itemize{
\item \code{iterator}: e.g. a for loop or a mapping function,
\item \code{tasks}: a (typically small) number of tasks,
\item \code{download}: download of one file,
\item \code{custom}: custom type, \code{format} must not be \code{NULL} for this type.
}}
\item{total}{Total number of progress units, or \code{NA} if it is unknown.
\code{cli_progress_update()} can update the total number of units. This is
handy if you don't know the size of a download at the beginning, and
also in some other cases. If \code{format} is set to \code{NULL}, \code{format} (plus
\code{format_done} and \code{format_failed}) will be updated when you change
\code{total} from \code{NA} to a number. I.e. default format strings will be
updated, custom ones won't be.}
\item{format}{Format string. It has to be specified for custom progress
bars, otherwise it is optional, and a default display is selected
based on the progress bat type and whether the number of total units
is known. Format strings may contain glue substitution, the support
pluralization and cli styling. See \link{progress-variables} for special
variables that you can use in the custom format.}
\item{format_done}{Format string for successful termination. By default
the same as \code{format}.}
\item{format_failed}{Format string for unsuccessful termination. By
default the same as \code{format}.}
\item{clear}{Whether to remove the progress bar from the screen after
it has terminated. Defaults to the \code{cli.progress_clear} option, or
\code{TRUE} if unset.}
\item{current}{Whether to use this progress bar as the current progress
bar of the calling function. See more at 'The current progress bar'
below.}
\item{auto_terminate}{Whether to terminate the progress bar if the
number of current units reaches the number of total units.}
\item{extra}{Extra data to add to the progress bar. This can be
used in custom format strings for example. It should be a named list.
\code{cli_progress_update()} can update the extra data. Often you can get
away with referring to local variables in the format string, and
then you don't need to use this argument. Explicitly including these
constants or variables in \code{extra} can result in cleaner code. In
the rare cases when you need to refer to the same progress bar from
multiple functions, and you can them to \code{extra}.}
\item{.auto_close}{Whether to terminate the progress bar when the
calling function (or the one with execution environment in \code{.envir}
exits. (Auto termination does not work for progress bars created
from the global environment, e.g. from a script.)}
\item{.envir}{The environment to use for auto-termination and for glue
substitution. It is also used to find and set the current progress bar.}
\item{inc}{Increment in progress units. This is ignored if \code{set} is
not \code{NULL}.}
\item{set}{Set the current number of progress units to this value.
Ignored if \code{NULL}.}
\item{id}{Progress bar to update or terminate. If \code{NULL}, then the
current progress bar of the calling function (or \code{.envir} if
specified) is updated or terminated.}
\item{force}{Whether to force a display update, even if no update is
due.}
\item{result}{String to select successful or unsuccessful termination.
It is only used if the progress bar is not cleared from the screen.
It can be one of \code{"done"}, \code{"failed"}, \code{"clear"}, and \code{"auto"}.}
}
\value{
\code{cli_progress_bar()} returns the id of the new progress bar.
The id is a string constant.
\code{cli_progress_update()} returns the id of the progress bar,
invisibly.
\code{cli_progress_done()} returns \code{TRUE}, invisibly, always.
}
\description{
This is the reference manual of the three functions that create,
update and terminate progress bars. For a tutorial see the
\href{https://cli.r-lib.org/articles/progress.html}{cli progress bars}.
\code{cli_progress_bar()} creates a new progress bar.
\code{cli_progress_update()} updates the state of a progress bar, and
potentially the display as well.
\code{cli_progress_done()} terminates a progress bar.
}
\details{
\subsection{Basic usage}{
\code{cli_progress_bar()} creates a progress bar, \code{cli_progress_update()}
updates an existing progress bar, and \code{cli_progress_done()} terminates
it.
It is good practice to always set the \code{name} argument, to make the
progress bar more informative.
\if{html}{\out{
}}\preformatted{clean <- function() \{
cli_progress_bar("Cleaning data", total = 100)
for (i in 1:100) \{
Sys.sleep(5/100)
cli_progress_update()
\}
cli_progress_done()
\}
clean()
}\if{html}{\out{
}}
\if{html}{\figure{progress-1.svg}}
}
\subsection{Progress bar types}{
There are three builtin types of progress bars, and a custom type.
\if{html}{\out{
}}\preformatted{tasks <- function() \{
cli_progress_bar("Tasks", total = 3, type = "tasks")
for (i in 1:3) \{
Sys.sleep(1)
cli_progress_update()
\}
cli_progress_done()
\}
tasks()
}\if{html}{\out{
}}
\if{html}{\figure{progress-tasks.svg}}
}
\subsection{Unknown \code{total}}{
If \code{total} is not known, then cli shows a different progress bar.
Note that you can also set \code{total} in \code{cli_progress_update()}, if it
not known when the progress bar is created, but you learn it later.
\if{html}{\out{
}}\preformatted{nototal <- function() \{
cli_progress_bar("Parameter tuning")
for (i in 1:100) \{
Sys.sleep(3/100)
cli_progress_update()
\}
cli_progress_done()
\}
nototal()
}\if{html}{\out{
}}
\if{html}{\figure{progress-natotal.svg}}
}
\subsection{Clearing the progress bar}{
By default cli removes terminated progress bars from the screen, if
the terminal supports this. If you want to change this, use the
\code{clear} argument of \code{cli_progress_bar()}, or the \code{cli.progress_clear}
global option (see \link{cli-config}) to change this.
(In the cli documentation we usually set \code{cli.progress_clear} to \code{FALSE},
so users can see how finished progress bars look.)
In this example the first progress bar is cleared, the second is not.
\if{html}{\out{
}}\preformatted{fun <- function() \{
cli_progress_bar("Data cleaning", total = 100, clear = TRUE)
for (i in 1:100) \{
Sys.sleep(3/100)
cli_progress_update()
\}
cli_progress_bar("Parameter tuning", total = 100, clear = FALSE)
for (i in 1:100) \{
Sys.sleep(3/100)
cli_progress_update()
\}
\}
fun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-clear.svg}}
}
\subsection{Initial delay}{
Updating a progress bar on the screen is costly, so cli tries to avoid
it for quick loops. By default a progress bar is only shown after two
seconds, or after half of that if less than 50\% of the iterations are
complete. You can change the two second default with the
\code{cli.progress_show_after} global option (see \link{cli-config}).
(In the cli documentation we usually set \code{cli.progress_show_after} to
\code{0} (zero seconds), so progress bars are shown immediately.)
In this example we only show the progress bar after one second, because
more than 50\% of the iterations remain after one second.
\if{html}{\out{
}}\preformatted{fun <- function() \{
cli_alert("Starting now, at \{Sys.time()\}")
cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{pb_percent\} @ \{Sys.time()\}"
)
for (i in 1:100) \{
Sys.sleep(4/100)
cli_progress_update()
\}
\}
options(cli.progress_show_after = 2)
fun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-after.svg}}
}
\subsection{The \emph{current} progress bar}{
By default cli sets the new progress bar as the \emph{current} progress bar
of the calling function. The current progress bar is the default one
in cli progress bar operations. E.g. if no progress bar id is supplied
in \code{cli_progress_update()}, then the current progress bar is updated.
Every function can only have a single \emph{current} progress bar, and if a
new one is created, then the previous one (if any) is automatically
terminated. The current progress bar is also terminated when the function
that created it exits. Thanks to these rules, most often you don't need
to explicitly deal with progress bar ids, and you don't need to
explicitly call \code{cli_progress_done()}:
\if{html}{\out{
}}\preformatted{fun <- function() \{
cli_progress_bar("First step ", total = 100)
for (i in 1:100) \{
Sys.sleep(2/100)
cli_progress_update()
\}
cli_progress_bar("Second step", total = 100)
for (i in 1:100) \{
Sys.sleep(2/100)
cli_progress_update()
\}
\}
fun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-current.svg}}
}
\subsection{cli output while the progress bar is active}{
cli allows emitting regular cli output (alerts, headers, lists, etc.)
while a progress bar is active. On terminals that support this, cli
will remove the progress bar temporarily, emit the output, and then
restores the progress bar.
\if{html}{\out{
}}\preformatted{fun <- function() \{
cli_alert_info("Before the progress bar")
cli_progress_bar("Calculating", total = 100)
for (i in 1:50) \{
Sys.sleep(4/100)
cli_progress_update()
\}
cli_alert_info("Already half way!")
for (i in 1:50) \{
Sys.sleep(4/100)
cli_progress_update()
\}
cli_alert_info("All done")
\}
fun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-output.svg}}
See also \code{\link[=cli_progress_output]{cli_progress_output()}}, which sends text for the current
progress handler. E.g. in a Shiny app it will send the output to the
Shiny progress bar, as opposed to the \code{cli_alert()} etc. cli functions
which will print the text to the console.
}
\subsection{Custom formats}{
In addition to the builtin types, you can also specify a custom
format string. In this case \link[=progress-variables]{progress variables}
are probably useful to avoid calculating some progress bar quantities
like the elapsed time, of the ETA manually. You can also use your own
variables in the calling function:
\if{html}{\out{
}}\preformatted{fun <- function(urls) \{
cli_progress_bar(
format = paste0(
"\{pb_spin\} Downloading \{.path \{basename(url)\}\} ",
"[\{pb_current\}/\{pb_total\}] ETA:\{pb_eta\}"
),
format_done = paste0(
"\{col_green(symbol$tick)\} Downloaded \{pb_total\} files ",
"in \{pb_elapsed\}."
),,
total = length(urls)
)
for (url in urls) \{
cli_progress_update()
Sys.sleep(5/10)
\}
\}
fun(paste0("https://acme.com/data-", 1:10, ".zip"))
}\if{html}{\out{
}}
\if{html}{\figure{progress-format.svg}}
}
}
\seealso{
These functions support \link[=inline-markup]{inline markup}.
\code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} for simpler
progress messages.
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()},
\code{\link{progress-variables}}
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
\concept{progress bar functions}
cli/man/ansi_strip.Rd 0000644 0001762 0000144 00000001732 14521175065 014247 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_strip}
\alias{ansi_strip}
\title{Remove ANSI escape sequences from a string}
\usage{
ansi_strip(string, sgr = TRUE, csi = TRUE, link = TRUE)
}
\arguments{
\item{string}{The input string.}
\item{sgr}{Whether to remove for SGR (styling) control sequences.}
\item{csi}{Whether to remove for non-SGR control sequences.}
\item{link}{Whether to remove ANSI hyperlinks.}
}
\value{
The cleaned up string. Note that \code{ansi_strip()} always drops
the \code{cli_ansi_string} class, even if \code{sgr} and sci\code{are}FALSE`.
}
\description{
The input may be of class \code{cli_ansi_string} class, this is also dropped
from the result.
}
\examples{
ansi_strip(col_red("foobar")) == "foobar"
}
\seealso{
Other low level ANSI functions:
\code{\link{ansi_has_any}()},
\code{\link{ansi_hide_cursor}()},
\code{\link{ansi_regex}()},
\code{\link{ansi_string}()}
}
\concept{low level ANSI functions}
cli/man/cli_format_method.Rd 0000644 0001762 0000144 00000004030 14143453131 015536 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print.R
\name{cli_format_method}
\alias{cli_format_method}
\title{Create a format method for an object using cli tools}
\usage{
cli_format_method(expr, theme = getOption("cli.theme"))
}
\arguments{
\item{expr}{Expression that calls \verb{cli_*} methods, \code{\link[base:cat]{base::cat()}} or
\code{\link[base:print]{base::print()}} to format an object's printout.}
\item{theme}{Theme to use for the formatting.}
}
\value{
Character vector, one element for each line of the printout.
}
\description{
This method can be typically used in \code{format()} S3 methods. Then the
\code{print()} method of the class can be easily defined in terms of such a
\code{format()} method. See examples below.
}
\examples{
# Let's create format and print methods for a new S3 class that
# represents the an installed R package: `r_package`
# An `r_package` will contain the DESCRIPTION metadata of the package
# and also its installation path.
new_r_package <- function(pkg) {
tryCatch(
desc <- packageDescription(pkg),
warning = function(e) stop("Cannot find R package `", pkg, "`")
)
file <- dirname(attr(desc, "file"))
if (basename(file) != pkg) file <- dirname(file)
structure(
list(desc = unclass(desc), lib = dirname(file)),
class = "r_package"
)
}
format.r_package <- function(x, ...) {
cli_format_method({
cli_h1("{.pkg {x$desc$Package}} {cli::symbol$line} {x$desc$Title}")
cli_text("{x$desc$Description}")
cli_ul(c(
"Version: {x$desc$Version}",
if (!is.null(x$desc$Maintainer)) "Maintainer: {x$desc$Maintainer}",
"License: {x$desc$License}"
))
if (!is.na(x$desc$URL)) cli_text("See more at {.url {x$desc$URL}}")
})
}
# Now the print method is easy:
print.r_package <- function(x, ...) {
cat(format(x, ...), sep = "\n")
}
# Try it out
new_r_package("cli")
# The formatting of the output depends on the current theme:
opt <- options(cli.theme = simple_theme())
print(new_r_package("cli"))
options(opt) # <- restore theme
}
cli/man/cli_progress_styles.Rd 0000644 0001762 0000144 00000005622 14500305721 016163 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-bar.R
\name{cli_progress_styles}
\alias{cli_progress_styles}
\title{List of built-in cli progress styles}
\usage{
cli_progress_styles()
}
\value{
A named list with sublists containing elements
\code{complete}, \code{incomplete} and potentially \code{current}.
}
\description{
The following options are used to select a style:
\itemize{
\item \code{cli_progress_bar_style}
\item \code{cli_progress_bar_style_ascii}
\item \code{cli_progress_bar_style_unicode}
}
}
\details{
On Unicode terminals (if \code{\link[=is_utf8_output]{is_utf8_output()}} is \code{TRUE}), the
\code{cli_progress_bar_style_unicode} and \code{cli_progress_bar_style}
options are used.
On ASCII terminals (if \code{\link[=is_utf8_output]{is_utf8_output()}} is \code{FALSE}), the
\code{cli_pgoress_bar_style_ascii} and \code{cli_progress_bar_style} options
are are used.
\if{html}{\out{
}}\preformatted{for (style in names(cli_progress_styles())) \{
options(cli.progress_bar_style = style)
label <- ansi_align(paste0("Style '", style, "'"), 20)
print(cli_progress_demo(label, live = FALSE, at = 66, total = 100))
\}
options(cli.progress_var_style = NULL)
}\if{html}{\out{
}}
}
\seealso{
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{progress-variables}}
}
\concept{progress bar functions}
cli/man/get_spinner.Rd 0000644 0001762 0000144 00000002537 14300722604 014405 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spinner.R
\name{get_spinner}
\alias{get_spinner}
\title{Character vector to put a spinner on the screen}
\usage{
get_spinner(which = NULL)
}
\arguments{
\item{which}{The name of the chosen spinner. If \code{NULL}, then the default
is used, which can be customized via the \code{cli.spinner_unicode},
\code{cli.spinner_ascii} and \code{cli.spinner} options. (The latter applies to
both Unicode and ASCII displays. These options can be set to the name
of a built-in spinner, or to a list that has an entry called \code{frames},
a character vector of frames.}
}
\value{
A list with entries: \code{name}, \code{interval}: the suggested update
interval in milliseconds and \code{frames}: the character vector of the
spinner's frames.
}
\description{
\code{cli} contains many different spinners, you choose one according to your
taste.
}
\details{
\if{html}{\out{
}}\preformatted{options(cli.spinner = "hearts")
fun <- function() \{
cli_progress_bar("Spinning")
for (i in 1:100) \{
Sys.sleep(4/100)
cli_progress_update()
\}
\}
fun()
options(cli.spinner = NULL)
}\if{html}{\out{
}}
\if{html}{\figure{get-spinner.svg}}
}
\seealso{
Other spinners:
\code{\link{demo_spinners}()},
\code{\link{list_spinners}()},
\code{\link{make_spinner}()}
}
\concept{spinners}
cli/man/ansi_substr.Rd 0000644 0001762 0000144 00000003261 14143453131 014420 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_substr}
\alias{ansi_substr}
\title{Substring(s) of an ANSI colored string}
\usage{
ansi_substr(x, start, stop)
}
\arguments{
\item{x}{Character vector, potentially ANSI styled, or a vector to
coerced to character.}
\item{start}{Starting index or indices, recycled to match the length
of \code{x}.}
\item{stop}{Ending index or indices, recycled to match the length
of \code{x}.}
}
\value{
Character vector of the same length as \code{x}, containing
the requested substrings. ANSI styles are retained.
}
\description{
This is a color-aware counterpart of \code{\link[base:substr]{base::substr()}}.
It works exactly like the original, but keeps the colors
in the substrings. The ANSI escape sequences are ignored when
calculating the positions within the string.
}
\examples{
str <- paste(
col_red("red"),
"default",
col_green("green")
)
cat(str, "\n")
cat(ansi_substr(str, 1, 5), "\n")
cat(ansi_substr(str, 1, 15), "\n")
cat(ansi_substr(str, 3, 7), "\n")
substr(ansi_strip(str), 1, 5)
substr(ansi_strip(str), 1, 15)
substr(ansi_strip(str), 3, 7)
str2 <- paste(
"another",
col_red("multi-", style_underline("style")),
"text"
)
cat(str2, "\n")
cat(ansi_substr(c(str, str2), c(3,5), c(7, 18)), sep = "\n")
substr(ansi_strip(c(str, str2)), c(3,5), c(7, 18))
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/ansi_strwrap.Rd 0000644 0001762 0000144 00000003021 14143453131 014572 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_strwrap}
\alias{ansi_strwrap}
\title{Wrap an ANSI styled string to a certain width}
\usage{
ansi_strwrap(
x,
width = console_width(),
indent = 0,
exdent = 0,
simplify = TRUE
)
}
\arguments{
\item{x}{ANSI string.}
\item{width}{Width to wrap to.}
\item{indent}{Indentation of the first line of each paragraph.}
\item{exdent}{Indentation of the subsequent lines of each paragraph.}
\item{simplify}{Whether to return all wrapped strings in a single
character vector, or wrap each element of \code{x} independently and return
a list.}
}
\value{
If \code{simplify} is \code{FALSE}, then a list of character vectors,
each an ANSI string. Otherwise a single ANSI string vector.
}
\description{
This function is similar to \code{\link[base:strwrap]{base::strwrap()}}, but works on ANSI
styled strings, and leaves the styling intact.
}
\examples{
text <- cli:::lorem_ipsum()
# Highlight some words, that start with 's'
rexp <- gregexpr("\\\\b([sS][a-zA-Z]+)\\\\b", text)
regmatches(text, rexp) <- lapply(regmatches(text, rexp), col_red)
cat(text)
wrp <- ansi_strwrap(text, width = 40)
cat(wrp, sep = "\n")
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/simple_theme.Rd 0000644 0001762 0000144 00000013723 14332664317 014555 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simple-theme.R
\name{simple_theme}
\alias{simple_theme}
\title{A simple CLI theme}
\usage{
simple_theme(dark = getOption("cli.theme_dark", "auto"))
}
\arguments{
\item{dark}{Whether the theme should be optimized for a dark
background. If \code{"auto"}, then cli will try to detect this.
Detection usually works in recent RStudio versions, and in iTerm
on macOS, but not on other platforms.}
}
\description{
To use this theme, you can set it as the \code{cli.theme} option.
Note that this is in addition to the builtin theme, which is still in
effect.
}
\details{
\if{html}{\out{
}}\preformatted{show <- cli_div(theme = cli::simple_theme())
cli_h1("Heading 1")
cli_h2("Heading 2")
cli_h3("Heading 3")
cli_par()
cli_alert_danger("Danger alert")
cli_alert_warning("Warning alert")
cli_alert_info("Info alert")
cli_alert_success("Success alert")
cli_alert("Alert for starting a process or computation",
class = "alert-start")
cli_end()
cli_text("Packages and versions: \{.pkg cli\} \{.version 1.0.0\}.")
cli_text("Time intervals: \{.timestamp 3.4s\}")
cli_text("\{.emph Emphasis\} and \{.strong strong emphasis\}")
cli_text("This is a piece of code: \{.code sum(x) / length(x)\}")
cli_text("Function names: \{.fn cli::simple_theme\}")
cli_text("Files: \{.file /usr/bin/env\}")
cli_text("URLs: \{.url https://r-project.org\}")
cli_h2("Longer code chunk")
cli_par(class = "code R")
cli_verbatim(
'# window functions are useful for grouped mutates',
'mtcars \%>\%',
' group_by(cyl) \%>\%',
' mutate(rank = min_rank(desc(mpg)))')
cli_end(show)
}\if{html}{\out{
}}\if{html}{\out{
#>
#> ──Heading 1─────────────────────────────────────────────────────────
#>
#> ─ Heading 2 ──
#>
#> Heading 3
#> ✖ Danger alert
#> ! Warning alert
#> ℹ Info alert
#> ✔ Success alert
#> → Alert for starting a process or computation
#>
#> Packages and versions: cli1.0.0.
#> Time intervals: [3.4s]
#> Emphasis and strong emphasis
#> This is a piece of code: `sum(x) / length(x)`
#> Function names: `cli::simple_theme()`()
#> Files: /usr/bin/env
#> URLs: <https://r-project.org>
#>
#> ─ Longer code chunk ──
#> # window functions are useful for grouped mutates
#> mtcars %>%
#> group_by(cyl)%>%
#> mutate(rank = min_rank(desc(mpg)))
#>
}}
}
\seealso{
\link{themes}, \code{\link[=builtin_theme]{builtin_theme()}}.
}
cli/man/code_theme_list.Rd 0000644 0001762 0000144 00000003427 14143453131 015217 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prettycode.R
\name{code_theme_list}
\alias{code_theme_list}
\title{Syntax highlighting themes}
\usage{
code_theme_list()
}
\value{
Character vector of the built-in code theme names.
}
\description{
\code{code_theme_list()} lists the built-in code themes.
}
\section{Code themes}{
A theme is a list of character vectors, except for \code{bracket}, see below.
Each character vector must contain RGB colors (e.g. \code{"#a9a9a9"}),
and cli styles, e.g. \code{"bold"}. Entries in the list:
\itemize{
\item \code{reserved}: reserved words
\item \code{number}: numeric literals
\item \code{null}: the \code{NULL} constant
\item \code{operator}: operators, including assignment
\item \code{call}: function calls
\item \code{string}: character literals
\item \code{comment}: comments
\item \code{bracket}: brackets: \code{(){}[]} This is a list of character vectors,
to create "rainbow" brackets. It is recycled for deeply nested lists.
}
}
\section{The default code theme}{
In RStudio, it matches the current theme of the IDE.
You can use three options to customize the code theme:
\itemize{
\item If \code{cli.code_theme} is set, it is used.
\item Otherwise if R is running in RStudio and \code{cli.code_theme_rstudio} is
set, then it is used.
\item Otherwise if T is not running in RStudio and \code{cli.code_theme_terminal}
is set, then it is used.
}
You can set these options to the name of a built-in theme, or to list
that specifies a custom theme. See \code{\link[=code_theme_list]{code_theme_list()}} for the list
of the built-in themes.
}
\examples{
code_theme_list()
code_highlight(deparse(get), code_theme = "Solarized Dark")
}
\seealso{
Other syntax highlighting:
\code{\link{code_highlight}()}
}
\concept{syntax highlighting}
cli/man/cli.Rd 0000644 0001762 0000144 00000003703 14332664317 012646 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli}
\alias{cli}
\title{Compose multiple cli functions}
\usage{
cli(expr)
}
\arguments{
\item{expr}{Expression that contains \verb{cli_*} calls. Their output is
collected and sent as a single message.}
}
\value{
Nothing.
}
\description{
\code{cli()} will record all \verb{cli_*} calls in \code{expr}, and emit them together
in a single message. This is useful if you want to built a larger
piece of output from multiple \verb{cli_*} calls.
}
\details{
Use this function to build a more complex piece of CLI that would not
make sense to show in pieces.
\if{html}{\out{
#>
#> ──Title─────────────────────────────────────────────────────────────
#>
#> ── Subtitle ──
#>
#> • this
#> • that
#> • end
}}
}
cli/man/cli-config.Rd 0000644 0001762 0000144 00000032335 14521175065 014111 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/docs.R
\name{cli-config}
\alias{cli-config}
\title{cli environment variables and options}
\description{
cli environment variables and options
}
\section{User facing configuration}{
These are environment variables and options that uses may set, to modify
the behavior of cli.
\subsection{User facing environment variables}{
\subsection{\code{R_CLI_HYPERLINK_MODE}}{
Set to \code{posix} to force generating POSIX compatible ANSI hyperlinks.
If not set, then RStudio compatible links are generated. This is a
temporary crutch until RStudio handles POSIX hyperlinks correctly, and
after that it will be removed.
}
\subsection{\code{NO_COLOR}}{
Set to a nonempty value to turn off ANSI colors.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}
\subsection{\code{ESS_BACKGROUND_MODE}}{
Set this environment variable to \code{light} or \code{dark} to indicate dark mode
in Emacs. Once https://github.com/emacs-ess/ESS/pull/1178 is merged, ESS
will set this automatically.
}
\subsection{\code{R_CLI_DYNAMIC}}{
Set to \code{true}, \code{TRUE} or \code{True} to assume a dynamic terminal, that supports \verb{\\r}.
Set to anything else to assume a non-dynamic terminal.
See \code{\link[=is_dynamic_tty]{is_dynamic_tty()}}.
}
\subsection{\code{R_CLI_NUM_COLORS}}{
Set to a positive integer to assume a given number of colors.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}
\subsection{\code{R_CLI_HYPERLINKS}}{
Set to \code{true}, \code{TRUE} or \code{True} to tell cli that the terminal supports
ANSI hyperlinks.
Set to anything else to assume no hyperlink support.
See \code{\link[=style_hyperlink]{style_hyperlink()}}.
}
}
\subsection{User facing options}{
\subsection{\code{cli.ansi}}{
Set to \code{true}, \code{TRUE} or \code{True} to assume a terminal that supports ANSI
control sequences.
Set to anything else to assume a non-ANSI terminal.
See \code{\link[=is_ansi_tty]{is_ansi_tty()}}.
}
\subsection{\code{cli.condition_unicode_bullets}}{
\code{TRUE} or \code{FALSE} to force turn on or off the Unicode symbols when printing
conditions. E.g. in \code{format_error()}, \code{format_warning()}, \code{format_message()} and
also in \code{cli_abort()}, \code{cli_warn()} and \code{cli_inform()}.
}
\subsection{\code{cli.condition_width}}{
Integer scalar (or \code{Inf}) to set the console width when cli is formatting
errors, warnings or messages in \code{format_error()}, \code{format_warning()} and
\code{format_message()}. When formatting conditions this option takes precedence
over \code{cli.width}.
}
\subsection{\code{cli.default_handler}}{
General handler function for all cli conditions.
See \url{https://cli.r-lib.org/articles/semantic-cli.html#cli-messages-1}
}
\subsection{\code{cli.default_num_colors}}{
Default number of ANSI colors. This value is used if the number of colors
is not already set by
\itemize{
\item the \code{cli.num_colors} option,
\item the \code{R_CLI_NUM_COLORS} environment variable,
\item the \code{crayon.enabled} and \code{crayon.colors} options,
\item the \code{NO_COLOR} environment variable,
\item the \code{knitr.in.progress} option,
\item a \code{sink()} call for the stream.
}
You can also use this option if color support is detected correctly, but
you want to adjust the number of colors. E.g.
\itemize{
\item if \code{crayon.enabled} is \code{TRUE}, but \code{crayon.colors} is not,
\item in Emacs on Windows,
\item in terminals.
}
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}. See also the \code{cli.num_colors} option.
}
\subsection{\code{cli.dynamic}}{
Set to \code{TRUE} to assume a dynamic terminal, that supports \verb{\\r}.
Set to anything else to assume a non-dynamic terminal.
See \code{\link[=is_dynamic_tty]{is_dynamic_tty()}}.
}
\subsection{\code{cli.hide_cursor}}{
Whether the cli status bar should try to hide the cursor on terminals.
Set the \code{FALSE} if the hidden cursor causes issues.
}
\subsection{\code{cli.hyperlink}}{
Set to \code{true}, \code{TRUE} or \code{True} to tell cli that the terminal supports
ANSI hyperlinks.
Set to anything else to assume no hyperlink support.
See \code{\link[=style_hyperlink]{style_hyperlink()}}.
}
\subsection{\code{cli.ignore_unknown_rstudio_theme}}{
Set to \code{TRUE} to omit a warning for an unknown RStudio theme in
\code{code_highlight()}.
}
\subsection{\code{cli.num_colors}}{
Number of ANSI colors. See \code{\link[=num_ansi_colors]{num_ansi_colors()}}. See also the
\code{cli.default_num_colors} option.
}
\subsection{\code{cli.message_class}}{
Character vector of classes to add to cli's conditions.
}
\subsection{\code{cli.progress_bar_style}}{
Progress bar style.
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}
\subsection{\code{cli.progress_bar_style_ascii}}{
Progress bar style on ASCII consoles.
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}
\subsection{\code{cli.progress_bar_style_unicode}}{
Progress bar style on Unicode (UTF-8) consoles;
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}
\subsection{\code{cli.progress_clear}}{
Whether to clear terminated progress bar from the screen on dynamic terminals.
See \code{\link[=cli_progress_bar]{cli_progress_bar()}}.
}
\subsection{\code{cli.progress_demo_live}}{
Whether \code{cli_progress_demo()} should show a live demo, or just record the
progress bar frames.
}
\subsection{\code{cli.progress_format_download}}{
Default format string for \code{download} progress bars.
}
\subsection{\code{cli.progress_format_download_nototal}}{
Default format string for \code{download} progress bars with unknown totals.
}
\subsection{\code{cli.progress_format_iterator}}{
Default format string for \code{iterator} progress bars.
}
\subsection{\code{cli.progress_format_iterator_nototal}}{
Default format string for \code{iterator} progress bars with unknown total number
of progress units.
}
\subsection{\code{cli.progress_format_tasks}}{
Default format string for \code{tasks} progress bars.
}
\subsection{\code{cli.progress_format_tasks_nototal}}{
Default format string for \code{tasks} progress bars with unknown totals.
}
\subsection{\code{cli.progress_handlers}}{
Progress handlers to try.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_handlers_force}}{
Progress handlers that will always be used, even if another handler
was already selected.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_handlers_only}}{
Progress handlers to force, ignoring handlers set in
\code{cli.progress_handlers} and \code{cli.progress_handlers_force}.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_say_args}}{
Command line arguments for the \code{say} progress handlers.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_say_command}}{
External command to use in the \code{say} progress handler.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_say_frequency}}{
Minimum delay between \code{say} calls in the \code{say} progress handler.
\code{say} ignores very frequent updates, to keep the speech comprehensible.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}
\subsection{\code{cli.progress_show_after}}{
Delay before showing a progress bar, in seconds.
Progress bars that finish before this delay are not shown at all.
cli also shows progress bars that have more than 50\% to go after half of
this delay has passed.
}
\subsection{\code{cli.spinner}}{
Default spinner to use, see \code{\link[=get_spinner]{get_spinner()}}.
}
\subsection{\code{cli.spinner_ascii}}{
Default spinner to use on ASCII terminals, see \code{\link[=get_spinner]{get_spinner()}}.
}
\subsection{\code{cli.spinner_unicode}}{
Default spinner to use on Unicode terminals, see \code{\link[=get_spinner]{get_spinner()}}.
}
\subsection{\code{cli.theme}}{
Default cli theme, in addition to the built-in theme.
This option in intended for the package developers.
See \link{themes} and \code{\link[=start_app]{start_app()}}.
}
\subsection{\code{cli.theme_dark}}{
Whether cli should assume a dark theme for the builtin theme.
See \code{\link[=builtin_theme]{builtin_theme()}}.
}
\subsection{\code{cli.unicode}}{
Whether to assume a Unicode terminal.
If not set, then it is auto-detected.
See \code{\link[=is_utf8_output]{is_utf8_output()}}.
}
\subsection{\code{cli.user_theme}}{
cli user theme.
This option is intended for end users.
See \link{themes}.
}
\subsection{\code{cli.warn_inline_newlines}}{
Whether to emit a warning when cli replaces newline characters with
spaces within a \code{{.class }} inline style.
Defaults to \code{FALSE}.
}
\subsection{\code{cli.width}}{
Terminal width to assume.
If not set, then it is auto-detected.
See \code{\link[=console_width]{console_width()}}.
}
\subsection{\code{rlib_interactive}}{
Whether to assume an interactive R session.
If not set, then it is auto-detected.
}
\subsection{\code{width}}{
Terminal width.
This is used on some platforms, if \code{cli.width} is not set.
}
}
}
\section{Internal configuration}{
These are environment variables and options are for cli developers, users
should not rely on them as they may change between cli releases.
\subsection{Internal environment variables}{
\subsection{\code{ASCIICAST}}{
Used to detect an asciicast sub-process in RStudio.
}
\subsection{\code{ANSICON}}{
Used to detect ANSICON when detecting the number of ANSI colors.
}
\subsection{\code{CI}}{
Used to detect if the code is running on a CI.
If yes, we avoid ANSI hyperlinks.
}
\subsection{\code{CLI_DEBUG_BAD_END}}{
Whether to warn about \code{cli_end()} calls when there is no container to close.
}
\subsection{\code{CLI_NO_BUILTIN_THEME}}{
Set it to \code{true} to omit the builtin theme.
}
\subsection{\code{CLI_SPEED_TIME}}{
Can be used to speed up cli's timer.
It is a factor, e.g. setting it to 2 makes cli's time go twice as fast.
}
\subsection{\code{CLI_TICK_TIME}}{
How often the cli timer should alert, in milliseconds.
}
\subsection{\code{CMDER_ROOT}}{
Used to detect cmder when detecting the number of ANSI colors.
}
\subsection{\code{COLORTERM}}{
Used when detecting ANSI color support.
}
\subsection{\code{ConEmuANSI}}{
Used to detect ConEmu when detecting the number of ANSI colors.
}
\subsection{\code{EMACS}}{
Used to detect Emacs.
}
\subsection{\code{INSIDE_EMACS}}{
Used to detect Emacs.
}
\subsection{\code{NOT_CRAN}}{
Set to \code{true} to run tests / examples / checks, that do not run on CRAN.
}
\subsection{\verb{_R_CHECK_PACKAGE_NAME_}}{
Used to detect \verb{R CMD check}.
}
\subsection{\code{R_BROWSER}}{
Used to detect the RStudio build pane.
}
\subsection{\code{R_GUI_APP_VERSION}}{
Used to detect R.app on macOS, to decide if the console has ANSI control
sequences.
}
\subsection{\code{R_PACKAGE_DIR}}{
Used to detect if the code is running under \verb{R CMD INSTALL}.
}
\subsection{\code{R_PDFVIEWER}}{
Used to detect the RStudio build pane.
}
\subsection{\code{R_PROGRESS_NO_EXAMPLES}}{
Set to \code{true} to avoid running examples, outside of \verb{R CMD check}.
}
\subsection{\code{RSTUDIO}}{
Used to detect RStudio, in various functions.
}
\subsection{\code{RSTUDIO_CONSOLE_COLOR}}{
Used to detect the number of colors in RStudio.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}
\subsection{\code{RSTUDIO_CONSOLE_WIDTH}}{
Used to auto-detect console width in RStudio.
}
\subsection{\code{RSTUDIO_TERM}}{
Used to detect the RStudio build pane.
}
\subsection{\code{TEAMCITY_VERSION}}{
Used to detect the TeamCity CI, to turn off ANSI hyperlinks.
}
\subsection{\code{TERM}}{
Used to detect if the console has ANSI control sequences, in a terminal.
}
\subsection{\code{TERM_PROGRAM}}{
Used to detect iTerm for the dark theme detection and the ANSI hyperlink
support detection.
}
\subsection{\code{TERM_PROGRAM_VERSION}}{
Used to detect a suitable iTerm version for ANSI hyperlink support.
}
\subsection{\code{TESTTHAT}}{
Used to detect running in testthat tests.
}
\subsection{\code{VTE_VERSION}}{
Used to detect a suitable VTE version for ANSI hyperlinks.
}
}
\subsection{Internal options}{
\subsection{\code{cli__pb}}{
This option is set to the progress bar that is being updated, when
interpolating the format string.
}
\subsection{\code{cli.record}}{
Internal option to mark the state that cli is recording messages.
}
\subsection{\code{crayon.colors}}{
Deprecated option for the number of ANSI colors, that is still supported
by cli, when the new options are not set.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}
\subsection{\code{crayon.enabled}}{
Deprecated option to turn ANSI colors on/off.
This is still supported by cli when the new options are not set.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}
\subsection{\code{crayon.hyperlink}}{
Whether to assume ANSI hyperlink support.
See \code{\link[=ansi_has_hyperlink_support]{ansi_has_hyperlink_support()}}.
}
\subsection{\code{knitr.in.progress}}{
Used to detect knitr when detecting interactive sessions and ANSI color
support.
}
\subsection{\code{rstudio.notebook.executing}}{
Used to detect knitr when detecting interactive sessions.
}
}
}
cli/man/ansi_strsplit.Rd 0000644 0001762 0000144 00000003260 14143453131 014761 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_strsplit}
\alias{ansi_strsplit}
\title{Split an ANSI colored string}
\usage{
ansi_strsplit(x, split, ...)
}
\arguments{
\item{x}{Character vector, potentially ANSI styled, or a vector to
coerced to character.}
\item{split}{Character vector of length 1 (or object which can be coerced to
such) containing regular expression(s) (unless \code{fixed = TRUE}) to use
for splitting. If empty matches occur, in particular if \code{split} has
zero characters, \code{x} is split into single characters.}
\item{...}{Extra arguments are passed to \code{base::strsplit()}.}
}
\value{
A list of the same length as \code{x}, the \code{i}-th element of
which contains the vector of splits of \code{x[i]}. ANSI styles are
retained.
}
\description{
This is the color-aware counterpart of \code{\link[base:strsplit]{base::strsplit()}}.
It works almost exactly like the original, but keeps the colors in the
substrings.
}
\examples{
str <- paste0(
col_red("I am red---"),
col_green("and I am green-"),
style_underline("I underlined")
)
cat(str, "\n")
# split at dashes, keep color
cat(ansi_strsplit(str, "[-]+")[[1]], sep = "\n")
strsplit(ansi_strip(str), "[-]+")
# split to characters, keep color
cat(ansi_strsplit(str, "")[[1]], "\n", sep = " ")
strsplit(ansi_strip(str), "")
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/inline-markup.Rd 0000644 0001762 0000144 00000034624 14521175065 014655 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cliapp-docs.R
\name{inline-markup}
\alias{inline-markup}
\title{About inline markup in the semantic cli}
\description{
To learn how to use cli’s semantic markup, start with the ‘Building
a semantic CLI’ article at \url{https://cli.r-lib.org}.
}
\section{Command substitution}{
All text emitted by cli supports glue interpolation. Expressions
enclosed by braces will be evaluated as R code. See \code{\link[glue:glue]{glue::glue()}} for
details.
In addition to regular glue interpolation, cli can also add classes
to parts of the text, and these classes can be used in themes. For
example
\if{html}{\out{
}}\preformatted{cli_text("This is \{.emph important\}.")
}\if{html}{\out{
}}\if{html}{\out{
#> This is important.
}}
adds a class to the "important" word, class \code{"emph"}. Note that in this
case the string within the braces is usually not a valid R expression.
If you want to mix classes with interpolation, add another pair of
braces:
\if{html}{\out{
}}\preformatted{adjective <- "great"
cli_text("This is \{.emph \{adjective\}\}.")
}\if{html}{\out{
}}\if{html}{\out{
#> This is great.
}}
An inline class will always create a \code{span} element internally. So in
themes, you can use the \code{span.emph} CSS selector to change how inline
text is emphasized:
\if{html}{\out{
}}\preformatted{cli_div(theme = list(span.emph = list(color = "red")))
adjective <- "nice and red"
cli_text("This is \{.emph \{adjective\}\}.")
}\if{html}{\out{
}}\if{html}{\out{
#> This is nice and red.
}}
}
\section{Classes}{
The default theme defines the following inline classes:
\itemize{
\item \code{arg} for a function argument.
\item \code{cls} for an S3, S4, R6 or other class name.
\item \code{code} for a piece of code.
\item \code{dt} is used for the terms in a definition list (\code{\link[=cli_dl]{cli_dl()}}).
\item \code{dd} is used for the descriptions in a definition list (\code{\link[=cli_dl]{cli_dl()}}).
\item \code{email} for an email address.
If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.),
then cli creates a clickable link.
See \link{links} for more information about cli hyperlinks.
\item \code{emph} for emphasized text.
\item \code{envvar} for the name of an environment variable.
\item \code{field} for a generic field, e.g. in a named list.
\item \code{file} for a file name. If the terminal supports ANSI hyperlinks (e.g.
RStudio, iTerm2, etc.), then cli creates a clickable link that opens
the file in RStudio or with the default app for the file type.
See \link{links} for more information about cli hyperlinks.
\item \code{fn} for a function name. If it is in the \code{package::function_name}
form, and the terminal supports ANSI hyperlinks (e.g. RStudio,
iTerm2, etc.), then cli creates a clickable link.
See \link{links} for more information about cli hyperlinks.
\item \code{fun} same as \code{fn}.
\item \code{help} is a help page of a \emph{function}.
If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
then cli creates a clickable link. It supports link text.
See \link{links} for more information about cli hyperlinks.
\item \code{href} creates a hyperlink, potentially with a link text.
If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.),
then cli creates a clickable link.
See \link{links} for more information about cli hyperlinks.
\item \code{kbd} for a keyboard key.
\item \code{key} same as \code{kbd}.
\item \code{obj_type_friendly} formats the type of an R object in a readable way,
and it should be used with \code{{}}, see an example below.
\item \code{or} changes the string that separates the last two elements of
collapsed vectors (see below) from "and" to "or".
\item \code{path} for a path (the same as \code{file} in the default theme).
\item \code{pkg} for a package name.
\item \code{run} is an R expression, that is potentially clickable if the terminal
supports ANSI hyperlinks to runnable code (e.g. RStudio).
It supports link text. See \link{links} for more information about cli hyperlinks.
\item \code{str} for a double quoted string escaped by \code{\link[base:encodeString]{base::encodeString()}}.#' * \code{strong} for strong importance.
\item \code{topic} is a help page of a \emph{topic}.
If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
then cli creates a clickable link. It supports link text.
See \link{links} for more information about cli hyperlinks.
\item \code{type} formats the type of an R object in a readable way, and it
should be used with \code{{}}, see an example below.
\item \code{url} for a URL. If the terminal supports ANSI hyperlinks (e.g.
RStudio, iTerm2, etc.), then cli creates a clickable link.
See \link{links} for more information about cli hyperlinks.
\item \code{var} for a variable name.
\item \code{val} for a generic "value".
\item \code{vignette} is a vignette.
If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio),
then cli creates a clickable link. It supports link text.
See \link{links} for more information about cli hyperlinks.
}
\if{html}{\out{
}}
\subsection{Highlighting weird-looking values}{
Often it is useful to highlight a weird file or path name, e.g. one
that starts or ends with space characters. The built-in theme does this
for \code{.file}, \code{.path} and \code{.email} by default. You can highlight
any string inline by adding the \code{.q} class to it.
The current highlighting algorithm
\itemize{
\item adds single quotes to the string if it does not start or end with an
alphanumeric character, underscore, dot or forward slash.
\item Highlights the background colors of leading and trailing spaces on
terminals that support ANSI colors.
}
}
}
\section{Collapsing inline vectors}{
When cli performs inline text formatting, it automatically collapses
glue substitutions, after formatting. This is handy to create lists of
files, packages, etc.
\if{html}{\out{
#> Packages: pkg1, pkg2, and pkg3.
#> Packages: pkg1, pkg2, and pkg3.
}}
Class names are collapsed differently by default
\if{html}{\out{
}}\preformatted{x <- Sys.time()
cli_text("Hey, \{.var x\} has class \{.cls \{class(x)\}\}.")
}\if{html}{\out{
}}\if{html}{\out{
#> Hey, `x` has class <POSIXct/POSIXt>.
}}
By default cli truncates long vectors. The truncation limit is by default
twenty elements, but you can change it with the \code{vec-trunc} style.
\if{html}{\out{
#> Column names: mpg, cyl, disp, …, gear, and carb.
}}
}
\section{Formatting values}{
The \code{val} inline class formats values. By default (c.f. the built-in
theme), it calls the \code{\link[=cli_format]{cli_format()}} generic function, with the current
style as the argument. See \code{\link[=cli_format]{cli_format()}} for examples.
\code{str} is for formatting strings, it uses \code{\link[base:encodeString]{base::encodeString()}} with
double quotes.
}
\section{Escaping \verb{\{} and \verb{\}}}{
It might happen that you want to pass a string to \verb{cli_*} functions,
and you do \emph{not} want command substitution in that string, because it
might contain \verb{\{} and \verb{\}} characters. The simplest solution for this is
to refer to the string from a template:
\if{html}{\out{
}}\preformatted{msg <- "Error in if (ncol(dat$y)) \{: argument is of length zero"
cli_alert_warning("\{msg\}")
}\if{html}{\out{
}}\if{html}{\out{
#> ! Error in if (ncol(dat$y)) \{: argument is of length zero
}}
If you want to explicitly escape \verb{\{} and \verb{\}} characters, just double
them:
\if{html}{\out{
}}\preformatted{cli_alert_warning("A warning with \{\{ braces \}\}.")
}\if{html}{\out{
}}\if{html}{\out{
#> ! A warning with \{ braces \}.
}}
See also examples below.
}
\section{Pluralization}{
All cli commands that emit text support pluralization. Some examples:
\if{html}{\out{
#> ℹ Found 1 directory and 13 files.
#> Will install 3 packages: pkg1, pkg2, and pkg3
}}
See \link{pluralization} for details.
}
\section{Wrapping}{
Most cli containers wrap the text to width the container's width,
while observing margins requested by the theme.
To avoid a line break, you can use the UTF_8 non-breaking space
character: \verb{\\u00a0}. cli will not break a line here.
To force a line break, insert a form feed character: \verb{\\f} or
\verb{\\u000c}. cli will insert a line break there.
}
cli/man/ansi_html.Rd 0000644 0001762 0000144 00000002501 14143453131 014036 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_html}
\alias{ansi_html}
\title{Convert ANSI styled text to HTML}
\usage{
ansi_html(x, escape_reserved = TRUE, csi = c("drop", "keep"))
}
\arguments{
\item{x}{Input character vector.}
\item{escape_reserved}{Whether to escape characters that are reserved
in HTML (\code{&}, \code{<} and \code{>}).}
\item{csi}{What to do with non-SGR ANSI sequences, either \code{"keep"},
or \code{"drop"} them.}
}
\value{
Character vector of HTML.
}
\description{
Convert ANSI styled text to HTML
}
\examples{
\dontshow{if (cli:::has_packages(c("htmltools", "withr"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
## Syntax highlight the source code of an R function with ANSI tags,
## and export it to a HTML file.
code <- withr::with_options(
list(ansi.num_colors = 256),
code_highlight(format(ansi_html))
)
hcode <- paste(ansi_html(code), collapse = "\n")
css <- paste(format(ansi_html_style()), collapse= "\n")
page <- htmltools::tagList(
htmltools::tags$head(htmltools::tags$style(css)),
htmltools::tags$pre(htmltools::HTML(hcode))
)
if (interactive()) htmltools::html_print(page)
\dontshow{\}) # examplesIf}
}
\seealso{
Other ANSI to HTML conversion:
\code{\link{ansi_html_style}()}
}
\concept{ANSI to HTML conversion}
cli/man/match_selector_node.Rd 0000644 0001762 0000144 00000001707 14143453131 016070 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/themes.R
\name{match_selector_node}
\alias{match_selector_node}
\title{Match a selector node to a container}
\usage{
match_selector_node(node, cnt)
}
\arguments{
\item{node}{Selector node, as parsed by \code{parse_selector_node()}.}
\item{cnt}{Container node, has elements \code{tag}, \code{id}, \code{class}.
The selector node matches the container, if all these hold:
\itemize{
\item The id of the selector is missing or unique.
\item The tag of the selector is missing or unique.
\item The id of the container is missing or unique.
\item The tag of the container is unique.
\item If the selector specifies an id, it matches the id of the container.
\item If the selector specifies a tag, it matches the tag of the container.
\item If the selector specifies class names, the container has all these
classes.
}}
}
\description{
Match a selector node to a container
}
\keyword{internal}
cli/man/hash_animal.Rd 0000644 0001762 0000144 00000004734 14535114677 014354 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hash.R
\name{hash_animal}
\alias{hash_animal}
\alias{hash_raw_animal}
\alias{hash_obj_animal}
\title{Adjective-animal hash}
\usage{
hash_animal(x, n_adj = 2)
hash_raw_animal(x, n_adj = 2)
hash_obj_animal(x, n_adj = 2, serialize_version = 2)
}
\arguments{
\item{x}{Character vector. \code{NA} entries will have an \code{NA} hash.}
\item{n_adj}{Number of adjectives to use. It must be from 0 through 3.}
\item{serialize_version}{Workspace format version to use, see
\code{\link[base:serialize]{base::serialize()}}.}
}
\value{
A data frame with columns
\itemize{
\item \code{hash}: the hash value, a string.
\item \code{words}: list column with the adjectives and the animal name in a
character vector.
}
\code{hash_raw_animal()} and \code{hash_obj_animal()} return a list
with entries:
\itemize{
\item \code{hash}: the hash value, a string,
\item `words: the adjectives and the animal name in a character vector.
}
}
\description{
Adjective-animal hash
}
\details{
It uses the first 13 hexadecimal characters (out of the 32) of the MD5
hash of the input, and converts them into an adjective-animal form to
create a human readable hash.
\subsection{Number of possible hash values}{
\code{hash_animal()} uses 1748 animal names and
8946 different adjectives. The number of
different hashes you can get for different values of \code{n_adj}:\tabular{rr}{
\code{n_adj} \tab size of the hash table space \cr
0 \tab 1,748 \cr
1 \tab 15,637,608 \cr
2 \tab 139,894,041,168 \cr
3 \tab 1,251,492,092,288,928 \cr
}
}
\subsection{Source}{
The list of adjectives and animals comes from the ids package,
and in turn from
\url{https://github.com/a-type/adjective-adjective-animal}, and
from \verb{https://gfycat.com} (now gone).
}
\code{hash_raw_animal()} calculates the adjective-animal hash of
the bytes of a raw vector.
\code{hash_obj_animal()} calculates the adjective-animal hash of
an R object. The object is serialized into a binary vector first.
}
\examples{
hash_animal(c("foo", "bar"))
# if you increase `n_adj`, the shorter hash is a suffix of the longer:
hash_animal("cli package", 0)$hash
hash_animal("cli package", 1)$hash
hash_animal("cli package", 2)$hash
hash_animal("cli package", 3)$hash
}
\seealso{
the ids package for generating random adjective-animal ids
Other hash functions:
\code{\link{hash_emoji}()},
\code{\link{hash_md5}()},
\code{\link{hash_sha1}()},
\code{\link{hash_sha256}()}
}
\concept{hash functions}
cli/man/vt_output.Rd 0000644 0001762 0000144 00000002623 14312603722 014137 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vt.R
\name{vt_output}
\alias{vt_output}
\title{Simulate (a subset of) a VT-5xx ANSI terminal}
\usage{
vt_output(output, width = 80L, height = 25L)
}
\arguments{
\item{output}{Character vector or raw vector. Character vectors are
collapsed (without a separater), and converted to a raw vector using
\code{\link[base:rawConversion]{base::charToRaw()}}.}
\item{width}{Terminal width.}
\item{height}{Terminal height.}
}
\value{
Data frame with columns \code{lineno}, \code{segmentno}, \code{segment},
\code{attributes}.
}
\description{
This is utility function that calculates the state of a VT-5xx screen
after a certain set of output.
}
\details{
Currently it supports:
\itemize{
\item configurable terminal width and height
\item ASCII printable characters.
\item \verb{\\n}, \verb{\\r}.
\item ANSI SGR colors, 8 color mode, 256 color mode and true color mode.
\item Other ANSI SGR features: bold, italic, underline, strikethrough,
blink, inverse.
}
It does \emph{not} currently supports other features, mode notably:
\itemize{
\item Other ANSI control sequences and features. Other control sequences
are silently ignored.
\item Wide Unicode characters. Their width is not taken into account
correctly.
\item Unicode graphemes.
}
}
\note{
This function is experimental, and the virtual temrinal API will
likely change in future versions of cli.
}
cli/man/ansi_has_any.Rd 0000644 0001762 0000144 00000001710 14521175065 014524 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_has_any}
\alias{ansi_has_any}
\title{Check if a string has some ANSI styling}
\usage{
ansi_has_any(string, sgr = TRUE, csi = TRUE, link = TRUE)
}
\arguments{
\item{string}{The string to check. It can also be a character
vector.}
\item{sgr}{Whether to look for SGR (styling) control sequences.}
\item{csi}{Whether to look for non-SGR control sequences.}
\item{link}{Whether to look for ANSI hyperlinks.}
}
\value{
Logical vector, \code{TRUE} for the strings that have some
ANSI styling.
}
\description{
Check if a string has some ANSI styling
}
\examples{
## The second one has style if ANSI colors are supported
ansi_has_any("foobar")
ansi_has_any(col_red("foobar"))
}
\seealso{
Other low level ANSI functions:
\code{\link{ansi_hide_cursor}()},
\code{\link{ansi_regex}()},
\code{\link{ansi_string}()},
\code{\link{ansi_strip}()}
}
\concept{low level ANSI functions}
cli/man/cli_sitrep.Rd 0000644 0001762 0000144 00000001726 14143453131 014225 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sitrep.R
\name{cli_sitrep}
\alias{cli_sitrep}
\title{cli situation report}
\usage{
cli_sitrep()
}
\value{
Named list with entries listed above. It has a \code{cli_sitrep}
class, with a \code{print()} and \code{format()} method.
}
\description{
Contains currently:
\itemize{
\item \code{cli_unicode_option}: whether the \code{cli.unicode} option is set and its
value. See \code{\link[=is_utf8_output]{is_utf8_output()}}.
\item \code{symbol_charset}: the selected character set for \link{symbol}, UTF-8,
Windows, or ASCII.
\item \code{console_utf8}: whether the console supports UTF-8. See
\code{\link[base:l10n_info]{base::l10n_info()}}.
\item \code{latex_active}: whether we are inside knitr, creating a LaTeX
document.
\item \code{num_colors}: number of ANSI colors. See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
\item \code{console_with}: detected console width.
}
}
\examples{
cli_sitrep()
}
cli/man/ansi_align.Rd 0000644 0001762 0000144 00000010644 14332664317 014205 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_align}
\alias{ansi_align}
\title{Align an ANSI colored string}
\usage{
ansi_align(
text,
width = console_width(),
align = c("left", "center", "right"),
type = "width"
)
}
\arguments{
\item{text}{The character vector to align.}
\item{width}{Width of the field to align in.}
\item{align}{Whether to align \code{"left"}, \code{"center"} or \code{"right"}.}
\item{type}{Passed on to \code{\link[=ansi_nchar]{ansi_nchar()}} and there to \code{\link[=nchar]{nchar()}}}
}
\value{
The aligned character vector.
}
\description{
Align an ANSI colored string
}
\details{
\if{html}{\out{
}}\preformatted{str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, width = 30)
boxx(astr)
}\if{html}{\out{
}}\if{html}{\out{
#> ┌────────────────────────────────────┐
#> │ │
#> │ This is red │
#> │ This is bold │
#> │ │
#> └────────────────────────────────────┘
#> ┌────────────────────────────────────┐
#> │ │
#> │ This is red │
#> │ This is bold │
#> │ │
#> └────────────────────────────────────┘
}}
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/ansi_substring.Rd 0000644 0001762 0000144 00000003424 14143453131 015117 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_substring}
\alias{ansi_substring}
\title{Substring(s) of an ANSI colored string}
\usage{
ansi_substring(text, first, last = 1000000L)
}
\arguments{
\item{text}{Character vector, potentially ANSI styled, or a vector to
coerced to character. It is recycled to the longest of \code{first}
and \code{last}.}
\item{first}{Starting index or indices, recycled to match the length
of \code{x}.}
\item{last}{Ending index or indices, recycled to match the length
of \code{x}.}
}
\value{
Character vector of the same length as \code{x}, containing
the requested substrings. ANSI styles are retained.
}
\description{
This is the color-aware counterpart of \code{\link[base:substr]{base::substring()}}.
It works exactly like the original, but keeps the colors in the
substrings. The ANSI escape sequences are ignored when
calculating the positions within the string.
}
\examples{
str <- paste(
col_red("red"),
"default",
col_green("green")
)
cat(str, "\n")
cat(ansi_substring(str, 1, 5), "\n")
cat(ansi_substring(str, 1, 15), "\n")
cat(ansi_substring(str, 3, 7), "\n")
substring(ansi_strip(str), 1, 5)
substring(ansi_strip(str), 1, 15)
substring(ansi_strip(str), 3, 7)
str2 <- paste(
"another",
col_red("multi-", style_underline("style")),
"text"
)
cat(str2, "\n")
cat(ansi_substring(str2, c(3,5), c(7, 18)), sep = "\n")
substring(ansi_strip(str2), c(3,5), c(7, 18))
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/parse_selector.Rd 0000644 0001762 0000144 00000001546 14143453131 015102 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/themes.R
\name{parse_selector}
\alias{parse_selector}
\title{Parse a CSS3-like selector}
\usage{
parse_selector(x)
}
\arguments{
\item{x}{CSS3-like selector string.}
}
\description{
This is the rather small subset of CSS3 that is supported:
}
\details{
Selectors:
\itemize{
\item Type selectors, e.g. \code{input} selects all \verb{} elements.
\item Class selectors, e.g. \code{.index} selects any element that has a class
of "index".
\item ID selector. \verb{#toc} will match the element that has the ID \code{"toc"}.
}
Combinators:
\itemize{
\item Descendant combinator, i.e. the space, that combinator selects nodes
that are descendants of the first element. E.g. \verb{div span} will match
all \verb{} elements that are inside a \verb{
} element.
}
}
\keyword{internal}
cli/man/cli_process_start.Rd 0000644 0001762 0000144 00000011150 14500305721 015600 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/status-bar.R
\name{cli_process_start}
\alias{cli_process_start}
\alias{cli_process_done}
\alias{cli_process_failed}
\title{Indicate the start and termination of some computation in the status bar
(superseded)}
\usage{
cli_process_start(
msg,
msg_done = paste(msg, "... done"),
msg_failed = paste(msg, "... failed"),
on_exit = c("auto", "failed", "done"),
msg_class = "alert-info",
done_class = "alert-success",
failed_class = "alert-danger",
.auto_close = TRUE,
.envir = parent.frame()
)
cli_process_done(
id = NULL,
msg_done = NULL,
.envir = parent.frame(),
done_class = "alert-success"
)
cli_process_failed(
id = NULL,
msg = NULL,
msg_failed = NULL,
.envir = parent.frame(),
failed_class = "alert-danger"
)
}
\arguments{
\item{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 \code{\link[=console_width]{console_width()}}.}
\item{msg_done}{The message to use for successful termination.}
\item{msg_failed}{The message to use for unsuccessful termination.}
\item{on_exit}{Whether this process should fail or terminate
successfully when the calling function (or the environment in \code{.envir})
exits.}
\item{msg_class}{The style class to add to the message. Use an empty
string to suppress styling.}
\item{done_class}{The style class to add to the successful termination
message. Use an empty string to suppress styling.a}
\item{failed_class}{The style class to add to the unsuccessful
termination message. Use an empty string to suppress styling.a}
\item{.auto_close}{Whether to clear the status bar when the calling
function finishes (or \code{.envir} is removed from the stack, if
specified).}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-clear the status bar if \code{.auto_close} is \code{TRUE}.}
\item{id}{Id of the status bar container to clear. If \code{id} is not the id
of the current status bar (because it was overwritten by another
status bar container), then the status bar is not cleared. If \code{NULL}
(the default) then the status bar is always cleared.}
}
\value{
Id of the status bar container.
}
\description{
\strong{The \verb{cli_process_*()} functions are superseded by
the \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} functions,
because they have a better default behavior.}
Typically you call \code{cli_process_start()} to start the process, and then
\code{cli_process_done()} when it is done. If an error happens before
\code{cli_process_done()} is called, then cli automatically shows the message
for unsuccessful termination.
}
\details{
If you handle the errors of the process or computation, then you can do
the opposite: call \code{cli_process_start()} with \code{on_exit = "done"}, and
in the error handler call \code{cli_process_failed()}. cli will automatically
call \code{cli_process_done()} on successful termination, when the calling
function finishes.
See examples below.
}
\examples{
## Failure by default
fun <- function() {
cli_process_start("Calculating")
if (interactive()) Sys.sleep(1)
if (runif(1) < 0.5) stop("Failed")
cli_process_done()
}
tryCatch(fun(), error = function(err) err)
## Success by default
fun2 <- function() {
cli_process_start("Calculating", on_exit = "done")
tryCatch({
if (interactive()) Sys.sleep(1)
if (runif(1) < 0.5) stop("Failed")
}, error = function(err) cli_process_failed())
}
fun2()
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
The \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}}
functions, for a superior API.
Other status bar:
\code{\link{cli_status_clear}()},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()}
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
\concept{status bar}
cli/man/spark_line.Rd 0000644 0001762 0000144 00000001664 14332664317 014232 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spark.R
\name{spark_line}
\alias{spark_line}
\title{Draw a sparkline line graph with Braille characters.}
\usage{
spark_line(x)
}
\arguments{
\item{x}{A numeric vector between 0 and 1}
}
\description{
You might want to avoid sparklines on non-UTF-8 systems, because they
do not look good. You can use \code{\link[=is_utf8_output]{is_utf8_output()}} to test for support
for them.
}
\details{
\if{html}{\out{
}}
}
\seealso{
\code{\link[=spark_bar]{spark_bar()}}
}
cli/man/match_selector.Rd 0000644 0001762 0000144 00000001076 14143453131 015062 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/themes.R
\name{match_selector}
\alias{match_selector}
\title{Match a selector to a container stack}
\usage{
match_selector(sels, cnts)
}
\arguments{
\item{sels}{A list of selector nodes.}
\item{cnts}{A list of container nodes.
The last selector in the list must match the last container, so we
do the matching from the back. This is because we use this function
to calculate the style of newly encountered containers.}
}
\description{
Match a selector to a container stack
}
\keyword{internal}
cli/man/ansi_palettes.Rd 0000644 0001762 0000144 00000005060 14232501151 014711 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansi-palette.R
\docType{data}
\name{truecolor}
\alias{truecolor}
\alias{ansi_palettes}
\alias{ansi_palette_show}
\title{ANSI colors palettes}
\format{
\code{truecolor} is an integer scalar.
\code{ansi_palettes} is a data frame with one row for each palette,
and one column for each base ANSI color. \code{attr(ansi_palettes, "info")}
contains a list with information about each palette.
}
\usage{
truecolor
ansi_palettes
ansi_palette_show(palette = NULL, colors = num_ansi_colors(), rows = 4)
}
\arguments{
\item{palette}{The palette to show, in the same format as for the
\code{cli.palette} option, so it can be the name of a built-in palette,
of a list of 16 colors.}
\item{colors}{Number of ANSI colors to use the show the palette. If the
platform does not have sufficient support, the output might have
a lower color resolution. Without color support it will have no color
at all.}
\item{rows}{The number of colored rows to print.}
}
\value{
\code{ansi_palette_show} returns a character vector, the rows that
are printed to the screen, invisibly.
}
\description{
If your platform supports at least 256 colors, then you can configure
the colors that cli uses for the eight base and the eight bright colors.
(I.e. the colors of \code{\link[=col_black]{col_black()}}, \code{\link[=col_red]{col_red()}}, and \code{\link[=col_br_black]{col_br_black()}},
\code{\link[=col_br_red]{col_br_red()}}, etc.
}
\details{
\code{truecolor} is an integer constant for the number of 24 bit ANSI colors.
To customize the default palette, set the \code{cli.palette} option to the
name of a built-in palette (see \code{ansi_palettes()}), or the list of
16 colors. Colors can be specified with RGB colors strings:
\verb{#rrggbb} or R color names (see the output of \code{\link[grDevices:colors]{grDevices::colors()}}).
For example, you can put this in your R profile:
\if{html}{\out{
}}
It is currently not possible to configure the background colors
separately, these will be always the same as the foreground colors.
If your platform only has 256 colors, then the colors specified in the
palette have to be interpolated. On true color platforms they RGB
values are used as-is.
\code{ansi_palettes} is a data frame of the built-in palettes, each row
is one palette.
\code{ansi_palette_show()} shows the colors of an ANSI palette on the screen.
}
\examples{
ansi_palettes
ansi_palette_show("dichro", colors = truecolor)
}
\keyword{datasets}
cli/man/builtin_theme.Rd 0000644 0001762 0000144 00000012340 14535114677 014730 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/themes.R
\name{builtin_theme}
\alias{builtin_theme}
\title{The built-in CLI theme}
\usage{
builtin_theme(dark = getOption("cli.theme_dark", "auto"))
}
\arguments{
\item{dark}{Whether to use a dark theme. The \code{cli.theme_dark} option
can be used to request a dark theme explicitly. If this is not set,
or set to \code{"auto"}, then cli tries to detect a dark theme, this
works in recent RStudio versions and in iTerm on macOS.}
}
\value{
A named list, a CLI theme.
}
\description{
This theme is always active, and it is at the bottom of the theme
stack. See \link{themes}.
}
\section{Showcase}{
\if{html}{\out{
}}\preformatted{cli_h1("Heading 1")
cli_h2("Heading 2")
cli_h3("Heading 3")
cli_par()
cli_alert_danger("Danger alert")
cli_alert_warning("Warning alert")
cli_alert_info("Info alert")
cli_alert_success("Success alert")
cli_alert("Alert for starting a process or computation",
class = "alert-start")
cli_end()
cli_text("Packages and versions: \{.pkg cli\} \{.version 1.0.0\}.")
cli_text("Time intervals: \{.timestamp 3.4s\}")
cli_text("\{.emph Emphasis\} and \{.strong strong emphasis\}")
cli_text("This is a piece of code: \{.code sum(x) / length(x)\}")
cli_text("Function names: \{.fn cli::simple_theme\}")
cli_text("Files: \{.file /usr/bin/env\}")
cli_text("URLs: \{.url https://r-project.org\}")
cli_h2("Longer code chunk")
cli_par(class = "code R")
cli_verbatim(
'# window functions are useful for grouped mutates',
'mtcars \%>\%',
' group_by(cyl) \%>\%',
' mutate(rank = min_rank(desc(mpg)))')
}\if{html}{\out{
}}\if{html}{\out{
#> ──Heading 1─────────────────────────────────────────────────────────
#>
#> ── Heading 2 ──
#>
#> ── Heading 3
#> ✖ Danger alert
#> ! Warning alert
#> ℹ Info alert
#> ✔ Success alert
#> → Alert for starting a process or computation
#>
#> Packages and versions: cli 1.0.0.
#> Time intervals: [3.4s]
#> Emphasis and strong emphasis
#> This is a piece of code: `sum(x) / length(x)`
#> Function names: `cli::simple_theme()`
#> Files: /usr/bin/env
#> URLs: <https://r-project.org>
#>
#> ── Longer code chunk ──
#>
#> # window functions are useful for grouped mutates
#> mtcars %>%
#> group_by(cyl)%>%
#> mutate(rank = min_rank(desc(mpg)))
}}
}
\seealso{
\link{themes}, \code{\link[=simple_theme]{simple_theme()}}.
}
cli/man/style_hyperlink.Rd 0000644 0001762 0000144 00000002572 14312603722 015316 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansi-hyperlink.R
\name{style_hyperlink}
\alias{style_hyperlink}
\alias{ansi_has_hyperlink_support}
\alias{ansi_hyperlink_types}
\title{Terminal Hyperlinks}
\usage{
style_hyperlink(text, url, params = NULL)
ansi_has_hyperlink_support()
ansi_hyperlink_types()
}
\arguments{
\item{text}{Text to show. \code{text} and \code{url} are recycled to match their
length, via a \code{paste0()} call.}
\item{url}{URL to link to.}
\item{params}{A named character vector of additional parameters, or \code{NULL}.}
}
\value{
Styled \code{cli_ansi_string} for \code{style_hyperlink()}.
Logical scalar for \code{ansi_has_hyperlink_support()}.
}
\description{
\code{ansi_hyperlink()} creates an ANSI hyperlink.
}
\details{
This function is currently experimental. In particular, many of the
\verb{ansi_*()} functions do not support it properly.
\code{ansi_has_hyperlink_support()} checks if the current \code{stdout()}
supports hyperlinks.
See also
\url{https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda}.
\code{ansi_hyperlink_types()} checks if current \code{stdout()} supports various
types of hyperlinks. It returns a list with entries \code{href}, \code{run},
\code{help} and \code{vignettes}.
}
\examples{
cat("This is an", style_hyperlink("R", "https://r-project.org"), "link.\n")
ansi_has_hyperlink_support()
}
cli/man/roxygen/ 0000755 0001762 0000144 00000000000 14301737210 013265 5 ustar ligges users cli/man/roxygen/meta.R 0000644 0001762 0000144 00000001473 14301737210 014343 0 ustar ligges users
if (exists(".knitr_asciicast_process", envir = .GlobalEnv)) {
rm(list = ".knitr_asciicast_process", envir = .GlobalEnv)
}
asciicast::init_knitr_engine(
echo = TRUE,
echo_input = FALSE,
interactive = TRUE,
timeout = as.integer(Sys.getenv("ASCIICAST_TIMEOUT", 10)),
startup = quote({
options(cli.width = 70)
options(cli.progress_show_after = 0)
options(cli.progress_clear = FALSE)
library(cli)
set.seed(1)
})
)
knitr::opts_chunk$set(
asciicast_knitr_output = "html",
asciicast_include_style = FALSE,
asciicast_theme = "pkgdown"
)
list(
markdown = TRUE,
knitr_chunk_options = list(
cache = TRUE,
cache_lazy = FALSE,
cache.path = file.path(getwd(), "man/_cache/"),
fig.path = file.path(getwd(), "man/figures"),
error = TRUE
),
restrict_image_formats = TRUE
)
cli/man/list_spinners.Rd 0000644 0001762 0000144 00000000756 14143453131 014766 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spinner.R
\name{list_spinners}
\alias{list_spinners}
\title{List all available spinners}
\usage{
list_spinners()
}
\value{
Character vector of all available spinner names.
}
\description{
List all available spinners
}
\examples{
list_spinners()
get_spinner(list_spinners()[1])
}
\seealso{
Other spinners:
\code{\link{demo_spinners}()},
\code{\link{get_spinner}()},
\code{\link{make_spinner}()}
}
\concept{spinners}
cli/man/pluralization-helpers.Rd 0000644 0001762 0000144 00000001144 14143453131 016417 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pluralize.R
\name{no}
\alias{no}
\alias{qty}
\title{Pluralization helper functions}
\usage{
no(expr)
qty(expr)
}
\arguments{
\item{expr}{For \code{no()} it is an expression that is printed as "no" in
cli expressions, it is interpreted as a zero quantity. For \code{qty()}
an expression that sets the pluralization quantity without printing
anything. See examples below.}
}
\description{
Pluralization helper functions
}
\seealso{
Other pluralization:
\code{\link{pluralization}},
\code{\link{pluralize}()}
}
\concept{pluralization}
cli/man/rule.Rd 0000644 0001762 0000144 00000017732 14332664317 013055 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rules.R
\name{rule}
\alias{rule}
\title{Make a rule with one or two text labels}
\usage{
rule(
left = "",
center = "",
right = "",
line = 1,
col = NULL,
line_col = col,
background_col = NULL,
width = console_width()
)
}
\arguments{
\item{left}{Label to show on the left. It interferes with the \code{center}
label, only at most one of them can be present.}
\item{center}{Label to show at the center. It interferes with the
\code{left} and \code{right} labels.}
\item{right}{Label to show on the right. It interferes with the \code{center}
label, only at most one of them can be present.}
\item{line}{The character or string that is used to draw the line.
It can also \code{1} or \code{2}, to request a single line (Unicode, if
available), or a double line. Some strings are interpreted specially,
see \emph{Line styles} below.}
\item{col}{Color of text, and default line color. Either an ANSI style
function (see \link[=ansi-styles]{ANSI styles}), or a color name that is
passed to \code{\link[=make_ansi_style]{make_ansi_style()}}.}
\item{line_col, background_col}{Either a color name (used in
\code{\link[=make_ansi_style]{make_ansi_style()}}), or a style function (see
\link[=ansi-styles]{ANSI styles}), to color the line and background.}
\item{width}{Width of the rule. Defaults to the \code{width} option, see
\code{\link[base:options]{base::options()}}.}
}
\value{
Character scalar, the rule.
}
\description{
The rule can include either a centered text label, or labels on the
left and right side.
To color the labels, use the functions \verb{col_*}, \verb{bg_*} and \verb{style_*}
functions, see \link[=ansi-styles]{ANSI styles}, and the examples below.
To color the line, either these functions directly, or the \code{line_col}
option.
}
\details{
\subsection{Simple rule}{
\if{html}{\out{
}}
}
\subsection{Line styles}{
Some strings for the \code{line} argument are interpreted specially:
\itemize{
\item \code{"single"}: (same as \code{1}), a single line,
\item \code{"double"}: (same as \code{2}), a double line,
\item \code{"bar1"}, \code{"bar2"}, \code{"bar3"}, etc., \code{"bar8"} uses varying height bars.
}
\subsection{Double rule}{
\if{html}{\out{
}}
}
}
cli/man/cli_ol.Rd 0000644 0001762 0000144 00000010671 14500305721 013326 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_ol}
\alias{cli_ol}
\title{Ordered CLI list}
\usage{
cli_ol(
items = NULL,
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
}
\arguments{
\item{items}{If not \code{NULL}, then a character vector. Each element of
the vector will be one list item, and the list container will be
closed by default (see the \code{.close} argument).}
\item{id}{Id of the list container. Can be used for closing it with
\code{\link[=cli_end]{cli_end()}} or in themes. If \code{NULL}, then an id is generated and
returned invisibly.}
\item{class}{Class of the list container. Can be used in themes.}
\item{.close}{Whether to close the list container if the \code{items} were
specified. If \code{FALSE} then new items can be added to the list.}
\item{.auto_close}{Whether to close the container, when the calling
function finishes (or \code{.envir} is removed, if specified).}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-close the container if \code{.auto_close} is \code{TRUE}.}
}
\value{
The id of the new container element, invisibly.
}
\description{
An ordered list is a container, see \link{containers}.
}
\details{
\subsection{Adding all items at once}{
\if{html}{\out{
#> • one
#> 1. foo
#> 2. bar
#> 3. foobar
#> • two
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/ansi_string.Rd 0000644 0001762 0000144 00000001356 14521175065 014416 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_string}
\alias{ansi_string}
\title{Labels a character vector as containing ANSI control codes.}
\usage{
ansi_string(x)
}
\arguments{
\item{x}{A character vector or something that can be
coerced into one.}
}
\value{
A \code{cli_ansi_string} object, a subclass of
\code{character}, with the same length and contents
as \code{x}.
}
\description{
This function sets the class of its argument, activating
ANSI-string-specific methods such as for printing.
}
\seealso{
Other low level ANSI functions:
\code{\link{ansi_has_any}()},
\code{\link{ansi_hide_cursor}()},
\code{\link{ansi_regex}()},
\code{\link{ansi_strip}()}
}
\concept{low level ANSI functions}
cli/man/cli_progress_output.Rd 0000644 0001762 0000144 00000004530 14500305721 016175 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-client.R
\name{cli_progress_output}
\alias{cli_progress_output}
\title{Add text output to a progress bar}
\usage{
cli_progress_output(text, id = NULL, .envir = parent.frame())
}
\arguments{
\item{text}{Text to output. It is formatted via \code{\link[=cli_text]{cli_text()}}.}
\item{id}{Progress bar id. The default is the current progress bar.}
\item{.envir}{Environment to use for glue interpolation of \code{text}.}
}
\value{
\code{TRUE}, always.
}
\description{
The text is calculated via \code{\link[=cli_text]{cli_text()}}, so all cli features can be
used here, including progress variables.
}
\details{
The text is passed to the progress handler(s), that may or may not be
able to print it.
\if{html}{\out{
}}\preformatted{fun <- function() \{
cli_alert_info("Before the progress bar")
cli_progress_bar("Calculating", total = 100)
for (i in 1:50) \{
Sys.sleep(4/100)
cli_progress_update()
\}
cli_progress_output("Already half way!")
for (i in 1:50) \{
Sys.sleep(4/100)
cli_progress_update()
\}
cli_alert_info("All done")
\}
fun()
}\if{html}{\out{
}}
\if{html}{\figure{progress-output2.svg}}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()},
\code{\link{progress-variables}}
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
\concept{progress bar functions}
cli/man/tree.Rd 0000644 0001762 0000144 00000040161 14332664317 013035 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tree.R
\name{tree}
\alias{tree}
\title{Draw a tree}
\usage{
tree(
data,
root = data[[1]][[1]],
style = NULL,
width = console_width(),
trim = FALSE
)
}
\arguments{
\item{data}{Data frame that contains the tree structure.
The first column is an id, and the second column is a list column,
that contains the ids of the child nodes. The optional third column
may contain the text to print to annotate the node.}
\item{root}{The name of the root node.}
\item{style}{Optional box style list.}
\item{width}{Maximum width of the output. Defaults to the \code{width}
option, see \code{\link[base:options]{base::options()}}.}
\item{trim}{Whether to avoid traversing the same nodes multiple times.
If \code{TRUE} and \code{data} has a \code{trimmed} column, then that is used for
printing repeated nodes.}
}
\value{
Character vector, the lines of the tree drawing.
}
\description{
Draw a tree using box drawing characters. Unicode characters are
used if available. (Set the \code{cli.unicode} option if auto-detection
fails.)
}
\details{
A node might appear multiple times in the tree, or might not appear
at all.
\if{html}{\out{
}}
}
}
cli/man/cli_bullets.Rd 0000644 0001762 0000144 00000007740 14500305721 014371 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bullets.R
\name{cli_bullets}
\alias{cli_bullets}
\title{List of items}
\usage{
cli_bullets(text, id = NULL, class = NULL, .envir = parent.frame())
}
\arguments{
\item{text}{Character vector of items. See details below on how names
are interpreted.}
\item{id}{Optional id of the \code{div.bullets} element, can be used in themes.}
\item{class}{Optional additional class(es) for the \code{div.bullets} element.}
\item{.envir}{Environment to evaluate the glue expressions in.}
}
\description{
It is often useful to print out a list of items, tasks a function or
package performs, or a list of notes.
}
\details{
Items may be formatted differently, e.g. they can have a prefix symbol.
Formatting is specified by the names of \code{text}, and can be themed.
cli creates a \code{div} element of class \code{bullets} for the whole bullet list.
Each item is another \code{div} element of class \verb{bullet-}, where
\verb{} is the name of the entry in \code{text}. Entries in \code{text} without
a name create a \code{div} element of class \code{bullet-empty}, and if the
name is a single space character, the class is \code{bullet-space}.
The built-in theme defines the following item types:
\itemize{
\item No name: Item without a prefix.
\item \verb{ }: Indented item.
\item \code{*}: Item with a bullet.
\item \code{>}: Item with an arrow or pointer.
\item \code{v}: Item with a green "tick" symbol, like \code{\link[=cli_alert_success]{cli_alert_success()}}.
\item \code{x}: Item with a ref cross, like \code{\link[=cli_alert_danger]{cli_alert_danger()}}.
\item \code{!}: Item with a yellow exclamation mark, like \code{\link[=cli_alert_warning]{cli_alert_warning()}}.
\item \code{i}: Info item, like \code{\link[=cli_alert_info]{cli_alert_info()}}.
}
You can define new item type by simply defining theming for the
corresponding \verb{bullet-} classes.
\if{html}{\out{
}}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/test_that_cli.Rd 0000644 0001762 0000144 00000006200 14312603722 014707 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/test.R
\name{test_that_cli}
\alias{test_that_cli}
\title{Test cli output with testthat}
\usage{
test_that_cli(
desc,
code,
configs = c("plain", "ansi", "unicode", "fancy"),
links = NULL
)
}
\arguments{
\item{desc}{Test description, passed to \code{\link[testthat:test_that]{testthat::test_that()}}, after
appending the name of the cli configuration to it.}
\item{code}{Test code, it is modified to set up the cli config, and
then passed to \code{\link[testthat:test_that]{testthat::test_that()}}}
\item{configs}{cli configurations to test \code{code} with. The default is
\code{NULL}, which includes all possible configurations. It can also be a
character vector, to restrict the tests to some configurations only.
See available configurations below.}
\item{links}{Whether to run the code with various hyperlinks allowed.
If \code{NULL} then hyperlinks are turned off. Otherwise it can be a character
vector with possible hyperlink configurations:
\itemize{
\item \code{"all"}: turn on all hyperlinks,
\item \code{"none"}: turn off all hyperlinks.
}}
}
\description{
Use this function in your testthat test files, to test cli output.
It requires testthat edition 3, and works best with snapshot tests.
}
\details{
\code{test_that_cli()} calls \code{\link[testthat:test_that]{testthat::test_that()}} multiple times, with
different cli configurations. This makes it simple to test cli output
with and without ANSI colors, with and without Unicode characters.
Currently available configurations:
\itemize{
\item \code{plain}: no ANSI colors, ASCII characters only.
\item \code{ansi}: ANSI colors, ASCII characters only.
\item \code{unicode}: no ANSI colors, Unicode characters.
\item \code{fancy}; ANSI colors, Unicode characters.
}
See examples below and in cli's own tests, e.g. in
\url{https://github.com/r-lib/cli/tree/main/tests/testthat}
and the corresponding snapshots at
\url{https://github.com/r-lib/cli/tree/main/tests/testthat/_snaps}
\subsection{Important note regarding Windows}{
Because of base R's limitation to record Unicode characters on Windows,
we suggest that you record your snapshots on Unix, or you restrict
your tests to ASCII configurations.
Unicode tests on Windows are automatically skipped by testthat
currently.
}
}
\examples{
# testthat cannot record or compare snapshots when you run these
# examples interactively, so you might want to copy them into a test
# file
# Default configurations
cli::test_that_cli("success", {
testthat::local_edition(3)
testthat::expect_snapshot({
cli::cli_alert_success("wow")
})
})
# Only use two configurations, because this output does not have colors
cli::test_that_cli(configs = c("plain", "unicode"), "cat_bullet", {
testthat::local_edition(3)
testthat::expect_snapshot({
cli::cat_bullet(letters[1:5])
})
})
# You often need to evaluate all cli calls of a test case in the same
# environment. Use `local()` to do that:
cli::test_that_cli("theming", {
testthat::local_edition(3)
testthat::expect_snapshot(local({
cli::cli_div(theme = list(".alert" = list(before = "!!! ")))
cli::cli_alert("wow")
}))
})
}
cli/man/ansi_grep.Rd 0000644 0001762 0000144 00000003153 14301737210 014032 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_grep}
\alias{ansi_grep}
\alias{ansi_grepl}
\title{Like \code{\link[base:grep]{base::grep()}} and \code{\link[base:grep]{base::grepl()}}, but for ANSI strings}
\usage{
ansi_grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, ...)
ansi_grepl(pattern, x, ...)
}
\arguments{
\item{pattern}{Character scalar, regular expression or fixed string
(if \code{fixed = TRUE}), the pattern to search for. Other objects will be
coerced using \code{\link[=as.character]{as.character()}}.}
\item{x}{Character vector to search in. Other objects will be coerced
using \code{\link[=as.character]{as.character()}}.}
\item{ignore.case, perl, value}{Passed to \code{\link[base:grep]{base::grep()}}.}
\item{...}{Extra arguments are passed to \code{\link[base:grep]{base::grep()}} or \code{\link[base:grep]{base::grepl()}}.}
}
\value{
The same as \code{\link[base:grep]{base::grep()}} and \code{\link[base:grep]{base::grepl()}}, respectively.
}
\description{
First ANSI sequences will be stripped with \code{\link[=ansi_strip]{ansi_strip()}}, both
}
\details{
Note that these functions work on code points (or bytes if
\code{useBytes = TRUE}), and not graphemes.
Unlike \code{\link[base:grep]{base::grep()}} and \code{\link[base:grep]{base::grepl()}} these functions do not special
case factors.
Both \code{pattern} and \code{x} are converted to UTF-8.
}
\examples{
red_needle <- col_red("needle")
haystack <- c("foo", "needle", "foo")
green_haystack <- col_green(haystack)
ansi_grepl(red_needle, haystack)
ansi_grepl(red_needle, green_haystack)
}
cli/man/ansi_html_style.Rd 0000644 0001762 0000144 00000002747 14143453131 015272 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_html_style}
\alias{ansi_html_style}
\title{CSS styles for the output of \code{ansi_html()}}
\usage{
ansi_html_style(
colors = TRUE,
palette = c("vscode", "dichro", "vga", "winxp", "win10", "macos", "putty", "mirc",
"xterm", "ubuntu", "eclipse", "iterm", "iterm-pastel", "iterm-smoooooth",
"iterm-snazzy", "iterm-solarized", "iterm-tango")
)
}
\arguments{
\item{colors}{Whether or not to include colors. \code{FALSE} will not include
colors, \code{TRUE} or \code{8} will include eight colors (plus their bright
variants), \code{256} will include 256 colors.}
\item{palette}{Character scalar, palette to use for the first eight colors
plus their bright variants. Terminals define these colors differently,
and cli includes a couple of examples. Sources of palettes:
\itemize{
\item https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
\item iTerm2 builtin palettes
\item \url{https://github.com/sindresorhus/iterm2-snazzy}
}}
}
\value{
Named list of CSS declaration blocks, where the names are
CSS selectors. It has a \code{format()} and \code{print()} methods, which you
can use to write the output to a CSS or HTML file.
}
\description{
CSS styles for the output of \code{ansi_html()}
}
\examples{
ansi_html_style(colors = FALSE)
ansi_html_style(colors = 8, palette = "iterm-snazzy")
}
\seealso{
Other ANSI to HTML conversion:
\code{\link{ansi_html}()}
}
\concept{ANSI to HTML conversion}
cli/man/cli_ul.Rd 0000644 0001762 0000144 00000007010 14500305721 013325 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_ul}
\alias{cli_ul}
\title{Unordered CLI list}
\usage{
cli_ul(
items = NULL,
id = NULL,
class = NULL,
.close = TRUE,
.auto_close = TRUE,
.envir = parent.frame()
)
}
\arguments{
\item{items}{If not \code{NULL}, then a character vector. Each element of
the vector will be one list item, and the list container will be
closed by default (see the \code{.close} argument).}
\item{id}{Id of the list container. Can be used for closing it with
\code{\link[=cli_end]{cli_end()}} or in themes. If \code{NULL}, then an id is generated and
returned invisibly.}
\item{class}{Class of the list container. Can be used in themes.}
\item{.close}{Whether to close the list container if the \code{items} were
specified. If \code{FALSE} then new items can be added to the list.}
\item{.auto_close}{Whether to close the container, when the calling
function finishes (or \code{.envir} is removed, if specified).}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-close the container if \code{.auto_close} is \code{TRUE}.}
}
\value{
The id of the new container element, invisibly.
}
\description{
An unordered list is a container, see \link{containers}.
}
\details{
\subsection{Adding all items at once}{
\if{html}{\out{
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/ansi_hide_cursor.Rd 0000644 0001762 0000144 00000002461 14521175065 015414 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tty.R
\name{ansi_hide_cursor}
\alias{ansi_hide_cursor}
\alias{ansi_show_cursor}
\alias{ansi_with_hidden_cursor}
\title{Hide/show cursor in a terminal}
\usage{
ansi_hide_cursor(stream = "auto")
ansi_show_cursor(stream = "auto")
ansi_with_hidden_cursor(expr, stream = "auto")
}
\arguments{
\item{stream}{The stream to inspect or manipulate, an R connection
object. It can also be a string, one of \code{"auto"}, \code{"message"},
\code{"stdout"}, \code{"stderr"}. \code{"auto"} will select \code{stdout()} if the session is
interactive and there are no sinks, otherwise it will select \code{stderr()}.}
\item{expr}{R expression to evaluate.}
}
\description{
This only works in terminal emulators. In other environments, it
does nothing.
}
\details{
\code{ansi_hide_cursor()} hides the cursor.
\code{ansi_show_cursor()} shows the cursor.
\code{ansi_with_hidden_cursor()} temporarily hides the cursor for
evaluating an expression.
}
\seealso{
Other terminal capabilities:
\code{\link{is_ansi_tty}()},
\code{\link{is_dynamic_tty}()}
Other low level ANSI functions:
\code{\link{ansi_has_any}()},
\code{\link{ansi_regex}()},
\code{\link{ansi_string}()},
\code{\link{ansi_strip}()}
}
\concept{low level ANSI functions}
\concept{terminal capabilities}
cli/man/spark_bar.Rd 0000644 0001762 0000144 00000004667 14332664317 014055 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spark.R
\name{spark_bar}
\alias{spark_bar}
\title{Draw a sparkline bar graph with unicode block characters}
\usage{
spark_bar(x)
}
\arguments{
\item{x}{A numeric vector between 0 and 1}
}
\description{
Rendered using \href{https://en.wikipedia.org/wiki/Block_Elements}{block elements}.
In most common fixed width fonts these are rendered wider than regular
characters which means they are not suitable if you need precise alignment.
You might want to avoid sparklines on non-UTF-8 systems, because they
do not look good. You can use \code{\link[=is_utf8_output]{is_utf8_output()}} to test for support
for them.
}
\details{
\if{html}{\out{
}}
}
\seealso{
\code{\link[=spark_line]{spark_line()}}
}
cli/man/cli_list_themes.Rd 0000644 0001762 0000144 00000001453 14535114677 015252 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/themes.R
\name{cli_list_themes}
\alias{cli_list_themes}
\title{List the currently active themes}
\usage{
cli_list_themes()
}
\value{
A list of data frames with the active themes.
Each data frame row is a style that applies to selected CLI tree nodes.
Each data frame has columns:
\itemize{
\item \code{selector}: The original CSS-like selector string. See \link{themes}.
\item \code{parsed}: The parsed selector, as used by cli for matching to nodes.
\item \code{style}: The original style.
\item \code{cnt}: The id of the container the style is currently applied to, or
\code{NA} if the style is not used.
}
}
\description{
If there is no active app, then it calls \code{\link[=start_app]{start_app()}}.
}
\seealso{
\link{themes}
}
cli/man/cli_blockquote.Rd 0000644 0001762 0000144 00000006067 14500305721 015070 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_blockquote}
\alias{cli_blockquote}
\title{CLI block quote}
\usage{
cli_blockquote(
quote,
citation = NULL,
id = NULL,
class = NULL,
.envir = parent.frame()
)
}
\arguments{
\item{quote}{Text of the quotation.}
\item{citation}{Source of the quotation, typically a link or the name
of a person.}
\item{id}{Element id, a string. If \code{NULL}, then a new id is generated
and returned.}
\item{class}{Class name, sting. Can be used in themes.}
\item{.envir}{Environment to evaluate the glue expressions in. It is
also used to auto-close the container if \code{.auto_close} is \code{TRUE}.}
}
\description{
A section that is quoted from another source. It is typically indented.
}
\details{
\if{html}{\out{
}}\preformatted{evil <- paste(
"The real problem is that programmers have spent far too much time",
"worrying about efficiency in the wrong places and at the wrong",
"times; premature optimization is the root of all evil (or at least",
"most of it) in programming.")
cli_blockquote(evil, citation = "Donald Ervin Knuth")
}\if{html}{\out{
}}\if{html}{\out{
#>
#> “The real problem is that programmers have spent far
#> too much time worrying about efficiency in the wrong
#> places and at the wrong times; premature optimization
#> is the root of all evil (or at least most of it) in
#> programming.”
#> — Donald Ervin Knuth
#>
}}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_rule}},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/containers.Rd 0000644 0001762 0000144 00000006312 14332664317 014243 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cliapp-docs.R
\name{containers}
\alias{containers}
\title{About cli containers}
\description{
Container elements may contain other elements. Currently the following
commands create container elements: \code{\link[=cli_div]{cli_div()}}, \code{\link[=cli_par]{cli_par()}}, the list
elements: \code{\link[=cli_ul]{cli_ul()}}, \code{\link[=cli_ol]{cli_ol()}}, \code{\link[=cli_dl]{cli_dl()}}, and list items are
containers as well: \code{\link[=cli_li]{cli_li()}}.
}
\details{
\subsection{Themes}{
A container can add a new theme, which is removed when the container
exits.
\if{html}{\out{
}}
}
\subsection{Auto-closing}{
Container elements are closed with \code{\link[=cli_end]{cli_end()}}. For convenience,
by default they are closed automatically when the function that created
them terminated (either regularly or with an error). The default
behavior can be changed with the \code{.auto_close} argument.
\if{html}{\out{
}}\preformatted{div <- function() \{
cli_div(class = "tmp", theme = list(.tmp = list(color = "yellow")))
cli_text("This is yellow")
\}
div()
cli_text("This is not yellow any more")
}\if{html}{\out{
}}\if{html}{\out{
#> This is yellow
#> This is not yellow any more
}}
}
\subsection{Debugging}{
You can use the internal \code{cli:::cli_debug_doc()} function to see the
currently open containers.
\if{html}{\out{
}}
}
}
cli/man/cli_rule.Rd 0000644 0001762 0000144 00000006543 14500305721 013666 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_rule}
\alias{cli_rule}
\title{CLI horizontal rule}
\usage{
cli_rule(
left = "",
center = "",
right = "",
id = NULL,
.envir = parent.frame()
)
}
\arguments{
\item{left}{Label to show on the left. It interferes with the \code{center}
label, only at most one of them can be present.}
\item{center}{Label to show at the center. It interferes with the
\code{left} and \code{right} labels.}
\item{right}{Label to show on the right. It interferes with the \code{center}
label, only at most one of them can be present.}
\item{id}{Element id, a string. If \code{NULL}, then a new id is generated
and returned.}
\item{.envir}{Environment to evaluate the glue expressions in.}
}
\description{
It can be used to separate parts of the output.
}
\details{
\subsection{Inline styling and interpolation}{
\if{html}{\out{
}}
}
\subsection{Theming}{
The line style of the rule can be changed via the the \code{line-type}
property. Possible values are:
\itemize{
\item \code{"single"}: (same as \code{1}), a single line,
\item \code{"double"}: (same as \code{2}), a double line,
\item \code{"bar1"}, \code{"bar2"}, \code{"bar3"}, etc., \code{"bar8"} uses varying height bars.
}
Colors and background colors can similarly changed via a theme.
\if{html}{\out{
}}\preformatted{d <- cli_div(theme = list(rule = list(
color = "cyan",
"line-type" = "double")))
cli_rule("Summary", right = "\{.pkg mypackage\}")
cli_end(d)
}\if{html}{\out{
}}
}
}
\seealso{
This function supports \link[=inline-markup]{inline markup}.
Other functions supporting inline markup:
\code{\link{cli_abort}()},
\code{\link{cli_alert}()},
\code{\link{cli_blockquote}()},
\code{\link{cli_bullets_raw}()},
\code{\link{cli_bullets}()},
\code{\link{cli_dl}()},
\code{\link{cli_h1}()},
\code{\link{cli_li}()},
\code{\link{cli_ol}()},
\code{\link{cli_process_start}()},
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()},
\code{\link{cli_text}()},
\code{\link{cli_ul}()},
\code{\link{format_error}()},
\code{\link{format_inline}()}
}
\concept{functions supporting inline markup}
cli/man/ansi-styles.Rd 0000644 0001762 0000144 00000013514 14535431165 014351 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/zzz.R
\name{ansi-styles}
\alias{ansi-styles}
\alias{bg_black}
\alias{bg_blue}
\alias{bg_cyan}
\alias{bg_green}
\alias{bg_magenta}
\alias{bg_red}
\alias{bg_white}
\alias{bg_yellow}
\alias{bg_none}
\alias{bg_br_black}
\alias{bg_br_blue}
\alias{bg_br_cyan}
\alias{bg_br_green}
\alias{bg_br_magenta}
\alias{bg_br_red}
\alias{bg_br_white}
\alias{bg_br_yellow}
\alias{col_black}
\alias{col_blue}
\alias{col_cyan}
\alias{col_green}
\alias{col_magenta}
\alias{col_red}
\alias{col_white}
\alias{col_yellow}
\alias{col_grey}
\alias{col_silver}
\alias{col_none}
\alias{col_br_black}
\alias{col_br_blue}
\alias{col_br_cyan}
\alias{col_br_green}
\alias{col_br_magenta}
\alias{col_br_red}
\alias{col_br_white}
\alias{col_br_yellow}
\alias{style_dim}
\alias{style_blurred}
\alias{style_bold}
\alias{style_hidden}
\alias{style_inverse}
\alias{style_italic}
\alias{style_reset}
\alias{style_strikethrough}
\alias{style_underline}
\alias{style_no_bold}
\alias{style_no_blurred}
\alias{style_no_dim}
\alias{style_no_italic}
\alias{style_no_underline}
\alias{style_no_inverse}
\alias{style_no_hidden}
\alias{style_no_strikethrough}
\alias{style_no_color}
\alias{style_no_bg_color}
\title{ANSI colored text}
\usage{
bg_black(...)
bg_blue(...)
bg_cyan(...)
bg_green(...)
bg_magenta(...)
bg_red(...)
bg_white(...)
bg_yellow(...)
bg_none(...)
bg_br_black(...)
bg_br_blue(...)
bg_br_cyan(...)
bg_br_green(...)
bg_br_magenta(...)
bg_br_red(...)
bg_br_white(...)
bg_br_yellow(...)
col_black(...)
col_blue(...)
col_cyan(...)
col_green(...)
col_magenta(...)
col_red(...)
col_white(...)
col_yellow(...)
col_grey(...)
col_silver(...)
col_none(...)
col_br_black(...)
col_br_blue(...)
col_br_cyan(...)
col_br_green(...)
col_br_magenta(...)
col_br_red(...)
col_br_white(...)
col_br_yellow(...)
style_dim(...)
style_blurred(...)
style_bold(...)
style_hidden(...)
style_inverse(...)
style_italic(...)
style_reset(...)
style_strikethrough(...)
style_underline(...)
style_no_bold(...)
style_no_blurred(...)
style_no_dim(...)
style_no_italic(...)
style_no_underline(...)
style_no_inverse(...)
style_no_hidden(...)
style_no_strikethrough(...)
style_no_color(...)
style_no_bg_color(...)
}
\arguments{
\item{...}{Character strings, they will be pasted together with
\code{paste0()}, before applying the style function.}
}
\value{
An ANSI string (class \code{cli_ansi_string}), that contains ANSI
sequences, if the current platform supports them. You can simply
use \code{cat()} to print them to the terminal.
}
\description{
cli has a number of functions to color and style text at the command
line. They provide a more modern interface than the crayon package.
}
\details{
The \verb{col_*} functions change the (foreground) color to the text.
These are the eight original ANSI colors. Note that in some terminals,
they might actually look differently, as terminals have their own
settings for how to show them. \code{col_none()} is the default color, this
is useful in a substring of a colored string.
The \verb{col_br_*} functions are bright versions of the eight ANSI colors.
Note that on some terminal configurations and themes they might be the
same as the non-bright colors.
The \verb{bg_*} functions change the background color of the text.
These are the eight original ANSI background colors. These, too, can
vary in appearance, depending on terminal settings. \code{bg_none()} the
the default background color, this is useful in a substring of a
background-colored string.
The \verb{bg_br_*} functions are the bright versions of the eight ANSI
background colors. Note that on some terminal configurations and themes
they might be the same as the non-bright colors.
The \verb{style_*} functions apply other styling to the text. The currently
supported styling functions are:
\itemize{
\item \code{style_reset()} to remove any style, including color,
\item \code{style_bold()} for boldface / strong text, although some terminals
show a bright, high intensity text instead,
\item \code{style_dim()} (or \code{style_blurred()} reduced intensity text.
\item \code{style_italic()} (not widely supported).
\item \code{style_underline()},
\item \code{style_inverse()},
\item \code{style_hidden()},
\item \code{style_strikethrough()} (not widely supported).
}
The style functions take any number of character vectors as arguments,
and they concatenate them using \code{paste0()} before adding the style.
Styles can also be nested, and then inner style takes precedence, see
examples below.
Sometimes you want to revert back to the default text color, in the
middle of colored text, or you want to have a normal font in the middle
of italic text. You can use the \verb{style_no_*} functions for this. Every
\verb{style_*()} function has a \verb{style_no_*()} pair, which defends its
argument from taking on the style. See examples below.
}
\examples{
col_blue("Hello ", "world!")
cat(col_blue("Hello ", "world!"))
cat("... to highlight the", col_red("search term"),
"in a block of text\n")
## Style stack properly
cat(col_green(
"I am a green line ",
col_blue(style_underline(style_bold("with a blue substring"))),
" that becomes green again!"
))
error <- combine_ansi_styles("red", "bold")
warn <- combine_ansi_styles("magenta", "underline")
note <- col_cyan
cat(error("Error: subscript out of bounds!\n"))
cat(warn("Warning: shorter argument was recycled.\n"))
cat(note("Note: no such directory.\n"))
# style_no_* functions, note that the color is not removed
style_italic(col_green(paste0(
"italic before, ",
style_no_italic("normal here, "),
"italic after"
)))
# avoiding color for substring
style_italic(col_red(paste(
"red before",
col_none("not red between"),
"red after"
)))
}
\seealso{
Other ANSI styling:
\code{\link{combine_ansi_styles}()},
\code{\link{make_ansi_style}()},
\code{\link{num_ansi_colors}()}
}
\concept{ANSI styling}
cli/man/faq.Rd 0000644 0001762 0000144 00000005620 14232501151 012627 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/docs.R
\name{faq}
\alias{faq}
\title{Frequently Asked Questions}
\description{
Frequently Asked Questions
}
\details{
\subsection{My platform supports ANSI colors, why does cli not use them?}{
It is probably a mistake in the ANSI support detection algorithm. Please
open an issue at \url{https://github.com/r-lib/cli/issues} and do not forget
to tell us the details of your platform and terminal or GUI.
}
\subsection{How do I turn off ANSI colors and styles?}{
Set the \code{NO_COLOR} environment variable to a non-empty value. You can do
this in your \code{.Renviron} file (use \code{usethis::edit_r_environ()}).
If you want to do this for testthat tests, then consider using the 3rd
edition on testthat, which does turn off ANSI styling automatically
inside \code{test_that()}.
}
\subsection{cli does not show the output before \code{file.choose()}}{
Try calling \code{flush.console()} to flush the console, before
\code{file.choose()}. If flushing does not work and you are in RStudio, then
it is probably this RStudio bug:
\url{https://github.com/rstudio/rstudio/issues/8040} See more details at
\url{https://github.com/r-lib/cli/issues/151}
}
\subsection{Why are heading separators wider than my screen in RStudio?}{
The display width of some Unicode characters ambiguous in the Unicode
standard. Some software treats them as narrow (one column on the
screen), other as wide (two columns). In some terminal emulators (for
example iTerm2), you can configure the preferred behavior.
Unfortunately the box drawing characters that cli uses also have
ambiguous width.
In RStudio the behavior depends on the font. In particular, Consolas,
Courier and Inconsolata treats them as wide characters, so cli output
will not look great with these. Some good, modern fonts that look good
include Menlo, Fira Code and Source Code Pro.
If you do not want to change your font, you can also turn off Unicode
output, by setting the \code{cli.unicode} option:
\if{html}{\out{
}}
A related issue: \url{https://github.com/r-lib/cli/issues/320}
}
\subsection{Is there a suggested font to use with cli?}{
In modern terminals, cli output usually looks good.
If you see too wide heading separators in RStudio, then see the previous
question: Why are heading separators wider than my screen in RStudio?.
If some output is garbled, then cli probably misdetected Unicode support
for your terminal or font. You can try choosing a different font. In our
experience output looks good with Menlo, Fira Code and Source Code Pro.
Alternatively you can turn off Unicode output:
\if{html}{\out{
}}
If you think this is our fault, then please also file an issue at
\url{https://github.com/r-lib/cli/issues}
}
}
cli/man/ansi_toupper.Rd 0000644 0001762 0000144 00000004125 14143453131 014574 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_toupper}
\alias{ansi_toupper}
\alias{ansi_tolower}
\alias{ansi_chartr}
\title{ANSI character translation and case folding}
\usage{
ansi_toupper(x)
ansi_tolower(x)
ansi_chartr(old, new, x)
}
\arguments{
\item{x}{Input string. May have ANSI colors and styles.}
\item{old}{a character string specifying the characters to be
translated. If a character vector of length 2 or more is supplied,
the first element is used with a warning.}
\item{new}{a character string specifying the translations. If a
character vector of length 2 or more is supplied, the first element
is used with a warning.}
}
\value{
Character vector of the same length as \code{x}, containing
the translated strings. ANSI styles are retained.
}
\description{
There functions are similar to \code{\link[=toupper]{toupper()}}, \code{\link[=tolower]{tolower()}} and
\code{\link[=chartr]{chartr()}}, but they keep the ANSI colors of the string.
}
\examples{
ansi_toupper(col_red("Uppercase"))
ansi_tolower(col_red("LowerCase"))
x <- paste0(col_green("MiXeD"), col_red(" cAsE 123"))
ansi_chartr("iXs", "why", x)
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_trimws}()}
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_trimws}()}
Other ANSI string operations:
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
cli/man/progress-variables.Rd 0000644 0001762 0000144 00000041405 14500305721 015676 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-variables.R
\name{progress-variables}
\alias{progress-variables}
\alias{cli__pb_bar}
\alias{pb_bar}
\alias{cli__pb_current}
\alias{pb_current}
\alias{cli__pb_current_bytes}
\alias{pb_current_bytes}
\alias{cli__pb_elapsed}
\alias{pb_elapsed}
\alias{cli__pb_elapsed_clock}
\alias{pb_elapsed_clock}
\alias{cli__pb_elapsed_raw}
\alias{pb_elapsed_raw}
\alias{cli__pb_eta}
\alias{pb_eta}
\alias{cli__pb_eta_raw}
\alias{pb_eta_raw}
\alias{cli__pb_eta_str}
\alias{pb_eta_str}
\alias{cli__pb_extra}
\alias{pb_extra}
\alias{cli__pb_id}
\alias{pb_id}
\alias{cli__pb_name}
\alias{pb_name}
\alias{cli__pb_percent}
\alias{pb_percent}
\alias{cli__pb_pid}
\alias{pb_pid}
\alias{cli__pb_rate}
\alias{pb_rate}
\alias{cli__pb_rate_raw}
\alias{pb_rate_raw}
\alias{cli__pb_rate_bytes}
\alias{pb_rate_bytes}
\alias{cli__pb_spin}
\alias{pb_spin}
\alias{cli__pb_status}
\alias{pb_status}
\alias{cli__pb_timestamp}
\alias{pb_timestamp}
\alias{cli__pb_total}
\alias{pb_total}
\alias{cli__pb_total_bytes}
\alias{pb_total_bytes}
\title{Progress bar variables}
\description{
Progress bar variables
}
\details{
These variables can be used in cli progress bar format
strings. They are calculated on demand. To use a variable, e.g. \code{pb_bar}
in a package, you either need to to import \code{pb_bar} from cli, or use
the qualified form in the format string: \code{cli::pb_bar}.
Similarly, in R scripts, you can use \code{pb_bar} after \code{library(cli)},
or \code{cli::pb_bar} if you do not attach the cli package.
\subsection{\code{pb_bar}}{
Creates a visual progress bar. If the number of total units
is unknown, then it will return an empty string.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "Fitting model \{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Fitting model ███████████████████████████████ 66%
}}
}
\subsection{\code{pb_current}}{
The number of current progress units.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ⠙ Reading file 66/100
}}
}
\subsection{\code{pb_current_bytes}}{
The number of current progress units formatted as bytes.
The output has a constant width of six characters.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
format = "Got \{cli::pb_current_bytes\} in \{cli::pb_elapsed\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Got 524 kB in 5s
}}
}
\subsection{\code{pb_elapsed}}{
The elapsed time since the start of the progress bar. The time is
measured since the progress bar was created with \code{\link[=cli_progress_bar]{cli_progress_bar()}}
or similar.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{cli::pb_elapsed\}]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% [5s]
}}
}
\subsection{\code{pb_elapsed_clock}}{
The elapsed time, in \verb{hh::mm::ss} format.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{cli::pb_elapsed_clock\}]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% [00:00:05]
}}
}
\subsection{\code{pb_elapsed_raw}}{
The number of seconds since the start of the progress bar.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{round(cli::pb_elapsed_raw)\}s]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% [5s]
}}
}
\subsection{\code{pb_eta}}{
The estimated time until the end of the progress bar,
in human readable form.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | ETA: \{cli::pb_eta\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% | ETA: 3s
}}
}
\subsection{\code{pb_eta_raw}}{
The estimated time until the end of the progress
bar, in seconds. This is useful if you want to adjust the default
\code{pb_eta} display.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | ETA: \{round(cli::pb_eta_raw)\}s"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% | ETA: 3s
}}
}
\subsection{\code{pb_eta_str}}{
The estimated time until the end of the progress bar.
It includes the \code{"ETA:"} prefix. It is only shown if the time can be
estimated, otherwise it is the empty string.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | \{cli::pb_eta_str\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66% | ETA: 3s
}}
}
\subsection{\code{pb_extra}}{
\code{pb_extra} can be used to access extra data, see the \code{extra} argument
of \code{cli_progress_bar()} and \code{cli_progress_update()}.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
extra = list(user = whoami::username()),
format = "Cleaning cache for user '\{cli::pb_extra$user\}': \{cli::pb_current_bytes\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Cleaning cache for user 'gaborcsardi': 161 MB
}}
}
\subsection{\code{pb_id}}{
The id of the progress bar. The id has the format
\verb{cli--} where \verb{} is the process id, and
\verb{} is an integer counter that is incremented every time
cli needs a new unique id.
This is useful for debugging progress bars.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
format = "Progress bar '\{cli::pb_id\}' is at \{cli::pb_current\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Progress bar 'cli-82040-1814' is at 64
}}
}
\subsection{\code{pb_name}}{
The name of the progress bar. This is supplied by the
developer, and it is by default the empty string. A space character
is added to non-empty names.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
name = "Loading training data",
total = 100,
format = "\{cli::pb_name\} \{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Loading training data ███████████████████████████████ 66%
}}
}
\subsection{\code{pb_percent}}{
The percentage of the progress bar, always formatted
in three characters plus the percentage sign. If the total number of
units is unknown, then it is \code{" NA\%"}.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ███████████████████████████████ 66%
}}
}
\subsection{\code{pb_pid}}{
The integer process id of the progress bar. This is useful if you are
aggregating logging output or progress results from multiple processes.
}
\subsection{\code{pb_rate}}{
The progress rate, in number of units per second, formatted in a string.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 156,
format = "Reading input files \{pb_current\}/\{pb_total\} [\{pb_rate\}]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Reading input files 68/156 [14/s]
}}
}
\subsection{\code{pb_rate_raw}}{
The raw progress rate, in number of units per second.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 156,
format = "Reading input files \{pb_current\}/\{pb_total\} [\{round(pb_rate_raw)\}/s]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Reading input files 68/156 [14/s]
}}
}
\subsection{\code{pb_rate_bytes}}{
The progress rate, formatted as bytes per second, in human readable form.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 256 * 1024 * 1014,
format = paste0(
"Reading data \{pb_current_bytes\}/\{pb_total_bytes\} ",
"[\{ansi_trimws(pb_rate_bytes)\}]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Reading data 70 MB/266 MB [14 MB/s]
}}
}
\subsection{\code{pb_spin}}{
A spinner. The default spinner is selected via a \code{\link[=get_spinner]{get_spinner()}} call.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ⠙ Reading file 66/100
}}
}
\subsection{\code{pb_status}}{
The status string of the progress bar. By default this is an empty
string, but it is possible to set it in \code{\link[=cli_progress_bar]{cli_progress_bar()}}
and `cli_progress_update()].
\if{html}{\out{
}}
}
\subsection{\code{pb_timestamp}}{
A time stamp for the current time in ISO 8601 format.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
"Loading training data files",
format = "\{pb_timestamp\} \{pb_current\} (\{pb_rate\})"
}\if{html}{\out{
}}\if{html}{\out{
#> 2022-09-07T11:27:50+00:00 125 (25/s)
}}
}
\subsection{\code{pb_total}}{
The total number of progress units, or \code{NA} if the number of units is
unknown.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{
}}\if{html}{\out{
#> ⠙ Reading file 66/100
}}
}
\subsection{\code{pb_total_bytes}}{
The total number of progress units, formatted as
bytes, in a human readable format.
\if{html}{\out{
}}\preformatted{cli_progress_bar(
total = 256 * 1024 * 1014,
format = paste0(
"Reading data \{pb_current_bytes\}/\{pb_total_bytes\} ",
"[\{ansi_trimws(pb_rate_bytes)\}]"
)
}\if{html}{\out{
}}\if{html}{\out{
#> Reading data 70 MB/266 MB [14 MB/s]
}}
}
}
\seealso{
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()}
}
\concept{progress bar functions}
cli/man/is_ansi_tty.Rd 0000644 0001762 0000144 00000002144 14143453131 014410 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tty.R
\name{is_ansi_tty}
\alias{is_ansi_tty}
\title{Detect if a stream support ANSI escape characters}
\usage{
is_ansi_tty(stream = "auto")
}
\arguments{
\item{stream}{The stream to inspect or manipulate, an R connection
object. It can also be a string, one of \code{"auto"}, \code{"message"},
\code{"stdout"}, \code{"stderr"}. \code{"auto"} will select \code{stdout()} if the session is
interactive and there are no sinks, otherwise it will select \code{stderr()}.}
}
\value{
\code{TRUE} or \code{FALSE}.
}
\description{
We check that all of the following hold:
\itemize{
\item The stream is a terminal.
\item The platform is Unix.
\item R is not running inside R.app (the macOS GUI).
\item R is not running inside RStudio.
\item R is not running inside Emacs.
\item The terminal is not "dumb".
\item \code{stream} is either the standard output or the standard error stream.
}
}
\examples{
is_ansi_tty()
}
\seealso{
Other terminal capabilities:
\code{\link{ansi_hide_cursor}()},
\code{\link{is_dynamic_tty}()}
}
\concept{terminal capabilities}
cli/man/figures/ 0000755 0001762 0000144 00000000000 14500305721 013235 5 ustar ligges users cli/man/figures/README/ 0000755 0001762 0000144 00000000000 14343071116 014175 5 ustar ligges users cli/man/figures/README/lists-dark.svg 0000644 0001762 0000144 00000003327 14521141212 016771 0 ustar ligges users