The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
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.
Install the stable version from CRAN:
install.packages("cli")
Install the development version from GitHub:
::pak("r-lib/cli") pak
Some of the more commonly used cli elements, and features.
One liner messages to inform or warn.
<- c("foo", "bar", "foobar")
pkgs cli_alert_success("Downloaded {length(pkgs)} packages.")
<- "example.com:port"
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.
<- function() {
fun cli_ol()
cli_li("Item 1")
<- cli_ul()
ulid cli_li("Subitem 1")
cli_li("Subitem 2")
cli_end(ulid)
cli_li("Item 2")
cli_end()
}fun()
Theming via a CSS-like language.
<- function() {
fun cli_div(theme = list(span.emph = list(color = "orange")))
cli_text("This is very {.emph important}")
cli_end()
cli_text("Back to the {.emph previous theme}")
}fun()
Automatic command substitution via the glue package.
<- 123143123
size <- 1.3454
dt cli_alert_info(c(
"Downloaded {prettyunits::pretty_bytes(size)} in ",
"{prettyunits::pretty_sec(dt)}"))
Pluralization support.
<- 3
nfiles <- 1
ndirs cli_alert_info("Found {nfiles} file{?s} and {ndirs} director{?y/ies}.")
<- function() {
clean cli_progress_bar("Cleaning data", total = 100)
for (i in 1:100) {
Sys.sleep(5/100)
cli_progress_update()
}
}clean()
See at https://cli.r-lib.org/
and also in the installed package:
help(package = "cli")
.
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 © Posit Software, PBC
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.