cli v2.0.1


Monthly downloads



Helpers for Developing Command Line Interfaces

A suite of tools to build attractive command line interfaces ('CLIs'), from semantic elements: headings, lists, alerts, paragraphs, etc. Supports custom themes via a 'CSS'-like language. It also contains a number of lower level 'CLI' elements: rules, boxes, trees, and 'Unicode' symbols with 'ASCII' alternatives. It integrates with the 'crayon' package to support 'ANSI' terminal colors.



Helpers for Developing Command Line Interfaces

Linux Build
Status Windows Build
status CRAN RStudio mirror
downloads Coverage

A suite of tools to build attractive command line interfaces (CLIs), from semantic elements: headers, lists, alerts, paragraphs, etc. Supports theming via a CSS-like language. It also contains a number of lower level CLI elements: rules, boxes, trees, and Unicode symbols with ASCII alternatives. It integrates with the crayon package to support ANSI terminal colors.


  • Build a CLI using semantic elements: headings, lists, alerts, paragraphs.
  • Theming via a CSS-like language.
  • Terminal colors via the crayon package.
  • Create cli elements in subprocesses, using the callr package.
  • All cli text can contain interpreted string literals, via the glue package.
  • Support for pluralized messages.


Install the stable version from CRAN:


Short tour

Some of the more commonly used cli elements, and features.

Short alert messages

One liner messages to inform or warn.

pkgs <- c("foo", "bar", "foobar")
cli_alert_success("Downloaded {length(pkgs)} packages.")

db_url <- ""
cli_alert_info("Reopened database {.url {db_url}}.")

cli_alert_warning("Cannot reach GitHub, using local database cache.")

cli_alert_danger("Failed to connect to database.")

cli_alert("A generic alert")


Three levels of headings.

cli_h1("Heading 1")

cli_h2("Heading 2")

cli_h3("Heading 3")


Ordered, unordered and description lists, that can be nested.

fun <- function() {
  cli_li("Item 1")
  ulid <- cli_ul()
  cli_li("Subitem 1")
  cli_li("Subitem 2")
  cli_li("Item 2")


Theming via a CSS-like language.

fun <- function() {
  cli_div(theme = list(span.emph = list(color = "orange")))
  cli_text("This is very {.emph important}")
  cli_text("Back to the {.emph previous theme}")

Command substitution

Automatic command substitution via the glue package.

size <- 123143123
dt <- 1.3454
  "Downloaded {prettyunits::pretty_bytes(size)} in ",


Pluralization support.

nfiles <- 3
ndirs <- 1
cli_alert_info("Found {nfiles} file{?s} and {ndirs} director{?y/ies}.")


See at and also in the installed package: ?"inline-markup", ?containers, ?themes, ?pluralization.


MIT © RStudio

Functions in cli

Name Description
cli_end Close a CLI container
combine_ansi_styles Combine two or more ANSI styles
cli_par CLI paragraph
is_utf8_output Whether cli is emitting UTF-8 characters
cli_process_start Indicate the start and termination of some computation in the status bar
console_width Determine the width of the console
list_spinners List all available spinners
match_selector Match a selector to a container stack
make_spinner Create a spinner
cli_list_themes List the currently active themes
cli_sitrep cli situation report
cli_alert CLI alerts
make_ansi_style Create a new ANSI style
simple_theme A simple CLI theme
cli_rule CLI horizontal rule
cli_format Format a value for printing
cli_status Update the status bar
start_app Start, stop, query the default cli application
cli_li CLI list item(s)
cli_ol Ordered CLI list
cli_output_connection The connection option that cli would use
cli_ul Unordered CLI list
cat_line cat() helpers
inline-markup CLI inline markup
get_spinner Character vector to put a spinner on the screen
cli_verbatim CLI verbatim text
cli_status_clear Clear the status bar
symbol Various handy symbols to use in a command line UI
themes CLI themes
pluralization CLI pluralization
rule Make a rule with one or two text labels
demo_spinners Show a demo of some (by default all) spinners
containers CLI containers
tree Draw a tree
match_selector_node Match a selector node to a container
cli_status_update Update the status bar
cli_format_method Create a format method for an object using cli tools
cli_text CLI text
cli_h1 CLI headings
is_ansi_tty Detect if a stream support ANSI escape characters
parse_selector Parse a CSS3-like selector
no Pluralization helper functions
is_dynamic_tty Detect whether a stream supports \\r (Carriage return)
cli_code A block of code
cli_div Generic CLI container
ansi_hide_cursor Hide/show cursor in a terminal
list_border_styles Draw a banner-like box in the console
cli_blockquote CLI block quote
ansi-styles ANSI colored text
builtin_theme The built-in CLI theme
cli_dl Definition list
No Results!

Vignettes of cli

No Results!

Last month downloads


License MIT + file LICENSE
LazyData true
RoxygenNote 7.0.2
Encoding UTF-8
VignetteBuilder cli
NeedsCompilation no
Packaged 2020-01-07 21:33:38 UTC; gaborcsardi
Repository CRAN
Date/Publication 2020-01-08 23:01:45 UTC

Include our badge in your README