Skip to content

Helpers for Developing Command Line Interfaces

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 supports ANSI markup for terminal colors and font styles.


  • Build a CLI using semantic elements: headings, lists, alerts, paragraphs.
  • Theming via a CSS-like language.
  • Terminal colors and font styles.
  • All cli text can contain interpreted string literals, via the glue package.
  • Progress bars from R and C code.
  • Error and warning messages with rich text formatting.
  • Support for pluralized messages.
  • ANSI styled string manipulation.


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.")
#>  Downloaded 3 packages.                                                        
db_url <- ""
cli_alert_info("Reopened database {.url {db_url}}.")
#>  Reopened database <>.                                         
cli_alert_warning("Cannot reach GitHub, using local database cache.")
#> ! Cannot reach GitHub, using local database cache.                              
cli_alert_danger("Failed to connect to database.")
#>  Failed to connect to database.                                                
cli_alert("A generic alert")
#> → A generic alert                                                               


Three levels of headings.

cli_h1("Heading 1")
#> ── Heading 1 ───────────────────────────────────────────────────────────────────
cli_h2("Heading 2")
#> ── Heading 2 ──                                                                 
cli_h3("Heading 3")
#> ── 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")
#> 1. Item 1                                                                       
#>   • Subitem 1                                                                   
#>   • Subitem 2                                                                   
#> 2. 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}")
#> This is very important                                                          
#> Back to the previous theme                                                      

Command substitution

Automatic command substitution via the glue package.

size <- 123143123
dt <- 1.3454
  "Downloaded {prettyunits::pretty_bytes(size)} in ",
#>  Downloaded 123.14 MB in 1.3s                                                  


Pluralization support.

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

Progress bars

clean <- function() {
  cli_progress_bar("Cleaning data", total = 100)
  for (i in 1:100) {


See at and also in the installed package: help(package = "cli").

Code of Conduct

Please note that the cli project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.


MIT © RStudio