}}\preformatted{#> Found 2 files.
}
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.
}
}
\subsection{Use “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 “no” if the count
is zero, and prints the numeric count otherwise:\if{html}{\out{
}}\preformatted{#> Found 2 files.
}
}
\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{
}}\preformatted{#> Will remove the pkg1 package.
}\if{html}{\out{
}}\preformatted{#> Will remove the pkg1, pkg2 and pkg3 packages.
}
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 “no”, like this:\if{html}{\out{
}}\preformatted{#> Will remove the pkg1, pkg2 and pkg3 packages.
}
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
}
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
}
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{{}} substituions at all, but has
pluralization markup, and error is thrown.
}
}
\section{Rules}{
The exact rules of cli’s 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 (i.e. \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 with a preceding \code{{}} substitution, and error is thrown.
}
}
\subsection{Pluralization markup}{
\enumerate{
\item Pluralization markup start with \verb{\{?} and ends with \verb{\}}. It may not
contain \verb{\{} and \verb{\}} characters, so it may not contains \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} (include 0).
\item If there are three alternatives, the first one is used for \code{quantity == 0}, the second for \code{quantity == 1}, and the third otherwise.
}
}
}
cli/man/make_spinner.Rd 0000644 0001762 0000144 00000004706 13565765747 014576 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 = stderr(),
template = "{spin}",
static = c("dots", "print", "print_line", "silent")
)
}
\arguments{
\item{which}{The name of the chosen spinner. The default depends on
whether the platform supports Unicode.}
\item{stream}{The stream to use for the spinner. Typically this is
standard error, or maybe the standard output stream.}
\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}{
\preformatted{## Default spinner
sp1 <- make_spinner()
fun_with_spinner <- function() \{
lapply(1:100, function(x) \{ sp1$spin(); Sys.sleep(0.05) \})
sp1$finish()
\}
ansi_with_hidden_cursor(fun_with_spinner())
## Spinner with a template
sp2 <- make_spinner(template = "Computing \{spin\}")
fun_with_spinner2 <- function() \{
lapply(1:100, function(x) \{ sp2$spin(); Sys.sleep(0.05) \})
sp2$finish()
\}
ansi_with_hidden_cursor(fun_with_spinner2())
## Custom spinner
sp3 <- make_spinner("simpleDotsScrolling", template = "Downloading \{spin\}")
fun_with_spinner3 <- function() \{
lapply(1:100, function(x) \{ sp3$spin(); Sys.sleep(0.05) \})
sp2$finish()
\}
ansi_with_hidden_cursor(fun_with_spinner3())
}
}
\seealso{
Other spinners:
\code{\link{demo_spinners}()},
\code{\link{get_spinner}()},
\code{\link{list_spinners}()}
}
\concept{spinners}
cli/man/console_width.Rd 0000644 0001762 0000144 00000000671 13565765747 014761 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{RSTUDIO_CONSOLE_WIDTH} environment variable, if set.
Otherwise it uses the \code{width} option. If this is not set either,
then 80 is used.
}
cli/man/cli_text.Rd 0000644 0001762 0000144 00000001733 13565765747 013733 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{
It is wrapped to the screen width automatically. It may contain inline
markup. (See \link{inline-markup}.)
}
\examples{
cli_text("Hello world!")
cli_text(packageDescription("cli")$Description)
## Arguments are concatenated
cli_text("this", "that")
## Command substitution
greeting <- "Hello"
subject <- "world"
cli_text("{greeting} {subject}!")
## Inline theming
cli_text("The {.fn cli_text} function in the {.pkg cli} package")
## Use within container elements
ul <- cli_ul()
cli_li()
cli_text("{.emph First} item")
cli_li()
cli_text("{.emph Second} item")
cli_end(ul)
}
cli/man/cli_dl.Rd 0000644 0001762 0000144 00000002603 13565765747 013343 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,
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{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
retuned 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}.
}
\examples{
## Specifying the items at the beginning
cli_dl(c(foo = "one", bar = "two", baz = "three"))
## Adding items one by one
cli_dl()
cli_li(c(foo = "one"))
cli_li(c(bar = "two"))
cli_li(c(baz = "three"))
cli_end()
}
cli/man/cli_li.Rd 0000644 0001762 0000144 00000002351 13565765747 013350 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,
id = NULL,
class = NULL,
.auto_close = TRUE,
.envir = parent.frame()
)
}
\arguments{
\item{items}{Character vector of items, or \code{NULL}.}
\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
retuned 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}.
}
\examples{
## Adding items one by one
cli_ul()
cli_li("one")
cli_li("two")
cli_li("three")
cli_end()
## Complex item, added gradually.
cli_ul()
cli_li()
cli_verbatim("Beginning of the {.emph first} item")
cli_text("Still the first item")
cli_end()
cli_li("Second item")
cli_end()
}
cli/man/cli_format_method.Rd 0000644 0001762 0000144 00000004030 13571261512 015542 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/get_spinner.Rd 0000644 0001762 0000144 00000001441 13565765747 014431 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. The default depends on
whether the platform supports Unicode.}
}
\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.
}
\examples{
get_spinner()
get_spinner("shark")
}
\seealso{
Other spinners:
\code{\link{demo_spinners}()},
\code{\link{list_spinners}()},
\code{\link{make_spinner}()}
}
\concept{spinners}
cli/man/simple_theme.Rd 0000644 0001762 0000144 00000003642 13573304532 014550 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 optiomized 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{
Note that this is in addition to the builtin theme. To use this theme,
you can set it as the \code{cli.theme} option:
}
\details{
\preformatted{options(cli.theme = cli::simple_theme())
}
and then CLI apps started after this will use it as the default theme.
You can also use it temporarily, in a div element:\preformatted{cli_div(theme = cli::simple_theme())
}
}
\examples{
cli_div(theme = cli::simple_theme())
cli_h1("Heading 1")
cli_h2("Heading 2")
cli_h3("Heading 3")
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_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()
cli_h2("Even longer code chunk")
cli_par(class = "code R")
cli_verbatim(format(ls))
cli_end()
cli_end()
}
\seealso{
\link{themes}, \code{\link[=builtin_theme]{builtin_theme()}}.
}
cli/man/inline-markup.Rd 0000644 0001762 0000144 00000010521 13571734652 014652 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{CLI inline markup}
\description{
CLI inline markup
}
\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\preformatted{cli_text("This is \{.emph important\}.")
}
adds a class to the "important" word, class "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:\preformatted{adjective <- "great"
cli_text("This is \{.emph \{adjective\}\}.")
}
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:\preformatted{cli_div(theme = list(span.emph = list(color = "red")))
adjective <- "nice and red"
cli_text("This is \{.emph \{adjective\}\}.")
}
}
\section{Classes}{
The default theme defines the following inline classes:
\itemize{
\item \code{emph} for emphasized text.
\item \code{strong} for strong importance.
\item \code{code} for a piece of code.
\item \code{pkg} for a package name.
\item \code{fun} for a function name.
\item \code{arg} for a function argument.
\item \code{key} for a keyboard key.
\item \code{file} for a file name.
\item \code{path} for a path (essentially the same as \code{file}).
\item \code{email} for an email address.
\item \code{url} for a URL.
\item \code{var} for a variable name.
\item \code{envvar} for the name of an environment variable.
\item \code{val} for a "value".
}
See examples below.
You can simply add new classes by defining them in the theme, and then
using them, see the example below.
}
\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. See examples below.
}
\section{Formatting values}{
The \code{val} inline class formats values. By default (c.f. the builtin
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.
}
\section{Escaping \verb{\{} and \verb{\}}}{
It might happen that you want to pass a string to \verb{cli_*} functions,
and you do not_ want command substitution in that string, because it
might contain \verb{\}} and \verb{\{} characters. The simplest solution for this is
referring to the string from a template:\preformatted{msg <- "Error in if (ncol(dat$y)) \{: argument is of length zero"
cli_alert_warning("\{msg\}")
}
If you want to explicitly escape \verb{\{} and \verb{\}} characters, just double
them:\preformatted{cli_alert_warning("A warning with \{\{ braces \}\}")
}
See also examples below.
}
\section{Pluralization}{
All cli commands that emit text support pluralization. Some examples:\preformatted{cli_alert_info("Found \{ndirs\} diretor\{?y/ies\} and \{nfiles\} file\{?s\}.")
cli_text("Will install \{length(pkgs)\} package\{?s\}: \{.pkg \{pkgs\}\}")
}
See \link{pluralization} for details.
}
\examples{
## Some inline markup examples
cli_ul()
cli_li("{.emph Emphasized} text")
cli_li("{.strong Strong} importance")
cli_li("A piece of code: {.code sum(a) / length(a)}")
cli_li("A package name: {.pkg cli}")
cli_li("A function name: {.fn cli_text}")
cli_li("A keyboard key: press {.kbd ENTER}")
cli_li("A file name: {.file /usr/bin/env}")
cli_li("An email address: {.email bugs.bunny@acme.com}")
cli_li("A URL: {.url https://acme.com}")
cli_li("An environment variable: {.envvar R_LIBS}")
cli_end()
## Adding a new class
cli_div(theme = list(
span.myclass = list(color = "lightgrey"),
"span.myclass" = list(before = "["),
"span.myclass" = list(after = "]")))
cli_text("This is {.myclass in brackets}.")
cli_end()
## Collapsing
pkgs <- c("pkg1", "pkg2", "pkg3")
cli_text("Packages: {pkgs}.")
cli_text("Packages: {.pkg {pkgs}}")
## Escaping
msg <- "Error in if (ncol(dat$y)) {: argument is of length zero"
cli_alert_warning("{msg}")
cli_alert_warning("A warning with {{ braces }}")
}
cli/man/match_selector_node.Rd 0000644 0001762 0000144 00000001707 13565765747 016122 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 matxhes 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/cli_sitrep.Rd 0000644 0001762 0000144 00000001731 13565765747 014253 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 currenty:
\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[crayon:num_colors]{crayon::num_colors()}}.
\item \code{console_with}: detected console width.
}
}
\examples{
cli_sitrep()
}
cli/man/parse_selector.Rd 0000644 0001762 0000144 00000001537 13565765747 015134 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 "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 00000006674 13571723077 015636 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}
\usage{
cli_process_start(
msg,
msg_done = paste(msg, "... done"),
msg_failed = paste(msg, "... failed"),
on_exit = c("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
compuration. 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.x}
\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 ‘.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 `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{
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_fone()} 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{
Other status bar:
\code{\link{cli_status_clear}()},
\code{\link{cli_status_update}()},
\code{\link{cli_status}()}
}
\concept{status bar}
cli/man/match_selector.Rd 0000644 0001762 0000144 00000001076 13571261512 015066 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/builtin_theme.Rd 0000644 0001762 0000144 00000001330 13573307244 014720 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}.
}
\seealso{
\link{themes}, \code{\link[=simple_theme]{simple_theme()}}.
}
cli/man/list_spinners.Rd 0000644 0001762 0000144 00000000756 13565765747 015020 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 00000001111 13571261512 016415 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}}
}
\concept{pluralization}
cli/man/rule.Rd 0000644 0001762 0000144 00000005253 13571261512 013042 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}), 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}), 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.
}
\details{
To color the labels, use the functions \verb{col_*}, \verb{bg_*} and \verb{style_*}
functions, see \link{ansi-styles}, and the examples below.
To color the line, either these functions directly, or the \code{line_col}
option.
}
\section{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.
}
}
\examples{
## Simple rule
rule()
## Double rule
rule(line = 2)
## Bars
rule(line = "bar2")
rule(line = "bar5")
## Left label
rule(left = "Results")
## Centered label
rule(center = " * RESULTS * ")
## Colored labels
rule(center = col_red(" * RESULTS * "))
## Colored line
rule(center = col_red(" * RESULTS * "), line_col = "red")
## Custom line
rule(center = "TITLE", line = "~")
## More custom line
rule(center = "TITLE", line = col_blue("~-"))
## Even more custom line
rule(center = bg_red(" ", symbol$star, "TITLE",
symbol$star, " "),
line = "\u2582",
line_col = "orange")
}
cli/man/cli_ol.Rd 0000644 0001762 0000144 00000003116 13565765747 013356 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
retuned 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}.
}
\examples{
## Specifying the items at the beginning
cli_ol(c("one", "two", "three"))
## Adding items one by one
cli_ol()
cli_li("one")
cli_li("two")
cli_li("three")
cli_end()
## Nested lists
cli_div(theme = list(ol = list("margin-left" = 2)))
cli_ul()
cli_li("one")
cli_ol(c("foo", "bar", "foobar"))
cli_li("two")
cli_end()
cli_end()
}
cli/man/tree.Rd 0000644 0001762 0000144 00000007703 13565765747 013062 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 noded.}
}
\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.
}
\examples{
data <- data.frame(
stringsAsFactors = FALSE,
package = c("processx", "backports", "assertthat", "Matrix",
"magrittr", "rprojroot", "clisymbols", "prettyunits", "withr",
"desc", "igraph", "R6", "crayon", "debugme", "digest", "irlba",
"rcmdcheck", "callr", "pkgconfig", "lattice"),
dependencies = I(list(
c("assertthat", "crayon", "debugme", "R6"), character(0),
character(0), "lattice", character(0), "backports", character(0),
c("magrittr", "assertthat"), character(0),
c("assertthat", "R6", "crayon", "rprojroot"),
c("irlba", "magrittr", "Matrix", "pkgconfig"), character(0),
character(0), "crayon", character(0), "Matrix",
c("callr", "clisymbols", "crayon", "desc", "digest", "prettyunits",
"R6", "rprojroot", "withr"),
c("processx", "R6"), character(0), character(0)
))
)
tree(data)
tree(data, root = "rcmdcheck")
# Colored nodes
data$label <- paste(data$package,
style_dim(paste0("(", c("2.0.0.1", "1.1.1", "0.2.0", "1.2-11",
"1.5", "1.2", "1.2.0", "1.0.2", "2.0.0", "1.1.1.9000", "1.1.2",
"2.2.2", "1.3.4", "1.0.2", "0.6.12", "2.2.1", "1.2.1.9002",
"1.0.0.9000", "2.0.1", "0.20-35"), ")"))
)
roots <- ! data$package \%in\% unlist(data$dependencies)
data$label[roots] <- col_cyan(style_italic(data$label[roots]))
tree(data)
tree(data, root = "rcmdcheck")
# Trimming
pkgdeps <- list(
"dplyr@0.8.3" = c("assertthat@0.2.1", "glue@1.3.1", "magrittr@1.5",
"R6@2.4.0", "Rcpp@1.0.2", "rlang@0.4.0", "tibble@2.1.3",
"tidyselect@0.2.5"),
"assertthat@0.2.1" = character(),
"glue@1.3.1" = character(),
"magrittr@1.5" = character(),
"pkgconfig@2.0.3" = character(),
"R6@2.4.0" = character(),
"Rcpp@1.0.2" = character(),
"rlang@0.4.0" = character(),
"tibble@2.1.3" = c("cli@1.1.0", "crayon@1.3.4", "fansi@0.4.0",
"pillar@1.4.2", "pkgconfig@2.0.3", "rlang@0.4.0"),
"cli@1.1.0" = c("assertthat@0.2.1", "crayon@1.3.4"),
"crayon@1.3.4" = character(),
"fansi@0.4.0" = character(),
"pillar@1.4.2" = c("cli@1.1.0", "crayon@1.3.4", "fansi@0.4.0",
"rlang@0.4.0", "utf8@1.1.4", "vctrs@0.2.0"),
"utf8@1.1.4" = character(),
"vctrs@0.2.0" = c("backports@1.1.5", "ellipsis@0.3.0",
"digest@0.6.21", "glue@1.3.1", "rlang@0.4.0", "zeallot@0.1.0"),
"backports@1.1.5" = character(),
"ellipsis@0.3.0" = c("rlang@0.4.0"),
"digest@0.6.21" = character(),
"glue@1.3.1" = character(),
"zeallot@0.1.0" = character(),
"tidyselect@0.2.5" = c("glue@1.3.1", "purrr@1.3.1", "rlang@0.4.0",
"Rcpp@1.0.2"),
"purrr@0.3.3" = c("magrittr@1.5", "rlang@0.4.0")
)
pkgs <- data.frame(
stringsAsFactors = FALSE,
name = names(pkgdeps),
deps = I(unname(pkgdeps))
)
tree(pkgs)
tree(pkgs, trim = TRUE)
# Mark the trimmed nodes
pkgs$label <- pkgs$name
pkgs$trimmed <- paste(pkgs$name, " (trimmed)")
tree(pkgs, trim = TRUE)
}
cli/man/cli_ul.Rd 0000644 0001762 0000144 00000003146 13565765747 013367 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
retuned 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}.
}
\examples{
## Specifying the items at the beginning
cli_ul(c("one", "two", "three"))
## Adding items one by one
cli_ul()
cli_li("one")
cli_li("two")
cli_li("three")
cli_end()
## Complex item, added gradually.
cli_ul()
cli_li()
cli_verbatim("Beginning of the {.emph first} item")
cli_text("Still the first item")
cli_end()
cli_li("Second item")
cli_end()
}
cli/man/ansi_hide_cursor.Rd 0000644 0001762 0000144 00000001453 13565765747 015437 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 = stderr())
ansi_show_cursor(stream = stderr())
ansi_with_hidden_cursor(expr, stream = stderr())
}
\arguments{
\item{stream}{The stream of the terminal to output the ANSI sequence to.}
\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.
}
\concept{terminal capabiltiies}
cli/man/cli_list_themes.Rd 0000644 0001762 0000144 00000001444 13565765747 015266 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{
themes
}
cli/man/cli_blockquote.Rd 0000644 0001762 0000144 00000001533 13573304254 015072 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.
}
\examples{
cli_blockquote(cli:::lorem_ipsum(), citation = "Nobody, ever")
}
cli/man/containers.Rd 0000644 0001762 0000144 00000002263 13565765747 014264 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{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{
Container elements need to be closed with \code{\link[=cli_end]{cli_end()}}. For convenience,
they are have an \code{.auto_close} argument, which allows automatically
closing a container element, when the function that created it
terminates (either regularly, or with an error).
}
\examples{
## div with custom theme
d <- cli_div(theme = list(h1 = list(color = "blue",
"font-weight" = "bold")))
cli_h1("Custom title")
cli_end(d)
## Close automatically
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")
}
cli/man/cli_rule.Rd 0000644 0001762 0000144 00000003132 13565765747 013711 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. The line style of the
rule can be changed via the the \code{line-type} property. Possible values
are:
}
\details{
\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, see
examples below.
}
\examples{
cli_rule()
cli_text(packageDescription("cli")$Description)
cli_rule()
# Theming
d <- cli_div(theme = list(rule = list(
color = "blue",
"background-color" = "darkgrey",
"line-type" = "double")))
cli_rule("Left", right = "Right")
cli_end(d)
# Interpolation
cli_rule(left = "One plus one is {1+1}")
cli_rule(left = "Package {.pkg mypackage}")
}
cli/man/ansi-styles.Rd 0000644 0001762 0000144 00000006770 13571261512 014353 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/crayon.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{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{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}
\title{ANSI colored text}
\usage{
bg_black(...)
bg_blue(...)
bg_cyan(...)
bg_green(...)
bg_magenta(...)
bg_red(...)
bg_white(...)
bg_yellow(...)
col_black(...)
col_blue(...)
col_cyan(...)
col_green(...)
col_magenta(...)
col_red(...)
col_white(...)
col_yellow(...)
col_grey(...)
col_silver(...)
style_dim(...)
style_blurred(...)
style_bold(...)
style_hidden(...)
style_inverse(...)
style_italic(...)
style_reset(...)
style_strikethrough(...)
style_underline(...)
}
\arguments{
\item{...}{Character strings, they will be pasted together with
\code{paste0()}, before applying the style function.}
}
\value{
An ANSI string (class \code{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. These all use the crayon package under the hood, but provide a
slightly simpler interface.
}
\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.
The \verb{bg_*} functions change the background color of the text.
These are the eight original ANSI background colors. These, too, can
vary in appearence, depending on terminal settings.
The \verb{style_*} functions apply other styling to the text. The currently
supported styling funtions 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 `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.
}
\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"))
}
\seealso{
Other ANSI styling:
\code{\link{combine_ansi_styles}()},
\code{\link{make_ansi_style}()}
}
\concept{ANSI styling}
cli/man/is_ansi_tty.Rd 0000644 0001762 0000144 00000001457 13565765747 014450 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 = stderr())
}
\arguments{
\item{stream}{The stream to check.}
}
\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{is_dynamic_tty}()}
}
\concept{terminal capabilities}
cli/man/figures/ 0000755 0001762 0000144 00000000000 13572314354 013247 5 ustar ligges users cli/man/figures/README/ 0000755 0001762 0000144 00000000000 13573667570 014220 5 ustar ligges users cli/man/figures/README/unnamed-chunk-12.svg 0000644 0001762 0000144 00000002430 13573667464 017717 0 ustar ligges users