Skip to content

Introduction

To learn how to use cli’s semantic markup, start with the ‘Building a semantic CLI’ vignette.

More detailed summaries about various cli topics:

inline-markup
About inline markup in the semantic cli
containers
About cli containers
themes
About cli themes
pluralization
About cli pluralization

Semantic CLI Elements

cli()
Compose multiple cli functions
cli_alert() cli_alert_success() cli_alert_danger() cli_alert_warning() cli_alert_info()
CLI alerts
cli_blockquote()
CLI block quote
cli_bullets()
List of items
cli_bullets_raw() format_bullets_raw()
List of verbatim items
cli_code()
A block of code
cli_div()
Generic CLI container
cli_dl()
Definition list
cli_end()
Close a CLI container
cli_format()
Format a value for printing
cli_h1() cli_h2() cli_h3()
CLI headings
cli_li()
CLI list item(s)
cli_ol()
Ordered CLI list
cli_par()
CLI paragraph
cli_rule()
CLI horizontal rule
cli_text()
CLI text
cli_ul()
Unordered CLI list
cli_vec()
Add custom cli style to a vector
cli_verbatim()
CLI verbatim text
format_inline()
Format and returns a line of text

Themes

themes
About cli themes
builtin_theme()
The built-in CLI theme
simple_theme()
A simple CLI theme
cli_list_themes()
List the currently active themes

Pluralization

cli has tools to create messages that are printed correctly in singular and plural forms. See the ‘Pluralization’ article for an introduction.

pluralize()
String templating with pluralization
no() qty()
Pluralization helper functions

Progress bars

cli progress bars work well with other bits of the semantic cli API. See the ‘Introduction to Progress Bars in cli’ article for an introduction, and the ‘Advanced cli Progress Bars’ article for more advanced topics.

Create and update progress bars

cli_progress_along()
Add a progress bar to a mapping function or for loop
cli_progress_bar() cli_progress_update() cli_progress_done()
cli progress bars
cli_progress_message()
Simplified cli progress messages
cli_progress_output()
Add text output to a progress bar
cli_progress_step()
Simplified cli progress messages, with styling
progress-variables
Progress bar variables

Progress bars in C/C++

progress-c
The cli progress C API

Progress bar utilities

cli_progress_builtin_handlers()
cli progress handlers
cli_progress_demo()
cli progress bar demo
cli_progress_styles()
List of built-in cli progress styles
cli_progress_num() cli_progress_cleanup()
Progress bar utility functions.

Terminal Colors and Styles

ANSI and/or UTF-8 String Manipulation

ansi_align()
Align an ANSI colored string
ansi_columns()
Format a character vector in multiple columns
ansi_grep() ansi_grepl()
Like base::grep() and base::grepl(), but for ANSI strings
ansi_has_any()
Check if a string has some ANSI styling
ansi_html()
Convert ANSI styled text to HTML
ansi_html_style()
CSS styles for the output of ansi_html()
ansi_nchar()
Count number of characters in an ANSI colored string
ansi_nzchar()
Like base::nzchar(), but for ANSI strings
ansi_regex()
Perl compatible regular expression that matches ANSI escape sequences
ansi_simplify()
Simplify ANSI styling tags
ansi_strip()
Remove ANSI escape sequences from a string
ansi_strsplit()
Split an ANSI colored string
ansi_strtrim()
Truncate an ANSI string
ansi_strwrap()
Wrap an ANSI styled string to a certain width
ansi_substr()
Substring(s) of an ANSI colored string
ansi_substring()
Substring(s) of an ANSI colored string
ansi_toupper() ansi_tolower() ansi_chartr()
ANSI character translation and case folding
ansi_trimws()
Remove leading and/or trailing whitespace from an ANSI string
utf8_graphemes()
Break an UTF-8 character vector into grapheme clusters
utf8_nchar()
Count the number of characters in a character vector
utf8_substr()
Substring of an UTF-8 string

Format and signal errors with cli formatting

cli_abort() cli_warn() cli_inform()
Signal an error, warning or message with a cli formatted message
format_error() format_warning() format_message()
Format an error, warning or diagnostic message

Rules, Boxes, Trees, Spinners, etc.

This section documents cli functions that create various non-semantic cli output. See the ‘Rules, Boxes and Trees’ article for a quick overiew of most of them.

list_border_styles() boxx()
Draw a banner-like box in the console
demo_spinners()
Show a demo of some (by default all) spinners
get_spinner()
Character vector to put a spinner on the screen
list_spinners()
List all available spinners
symbol list_symbols()
Various handy symbols to use in a command line UI
make_spinner()
Create a spinner
rule()
Make a rule with one or two text labels
spark_bar()
Draw a sparkline bar graph with unicode block characters
spark_line()
Draw a sparkline line graph with Braille characters.
tree()
Draw a tree

Syntax Highlighting

code_highlight()
Syntax highlight R code
code_theme_list()
Syntax highlighting themes

ANSI Control Sequences

is_ansi_tty()
Detect if a stream support ANSI escape characters
ansi_hide_cursor() ansi_show_cursor() ansi_with_hidden_cursor()
Hide/show cursor in a terminal

Hashing

Utilities and Configuration

cat_line() cat_bullet() cat_boxx() cat_rule() cat_print()
cat() helpers
cli-config
cli environment variables and options
cli_debug_doc()
Debug cli internals
cli_format_method()
Create a format method for an object using cli tools
cli_output_connection()
The connection option that cli would use
cli_sitrep()
cli situation report
console_width()
Determine the width of the console
start_app() stop_app() default_app()
Start, stop, query the default cli application
diff_chr()
Compare two character vectors elementwise
diff_str()
Compare two character strings, character by character
is_dynamic_tty()
Detect whether a stream supports \\r (Carriage return)
is_utf8_output()
Whether cli is emitting UTF-8 characters
ruler()
Print the helpful ruler to the screen
test_that_cli()
Test cli output with testthat

Superseded functions

cli_process_start() cli_process_done() cli_process_failed()
Indicate the start and termination of some computation in the status bar (superseded)
cli_status()
Update the status bar (superseded)
cli_status_clear()
Clear the status bar (superseded)
cli_status_update()
Update the status bar (superseded)