cli

Tools for making beautiful & useful command line interfaces

https://github.com/r-lib/cli

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary

Keywords

cli r

Keywords from Contributors

tidyverse package-creation pandoc rmarkdown travis-ci coverage-report coverage codecov network-analysis mathematics
Last synced: 6 months ago · JSON representation

Repository

Tools for making beautiful & useful command line interfaces

Basic Info
  • Host: GitHub
  • Owner: r-lib
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage: https://cli.r-lib.org/
  • Size: 30.9 MB
Statistics
  • Stars: 676
  • Watchers: 6
  • Forks: 74
  • Open Issues: 103
  • Releases: 26
Topics
cli r
Created almost 9 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

---
title: cli
output:
  github_document:
always_allow_html: yes
---



```{r, include = FALSE, cache = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README",
  out.width = "100%",
  cache = TRUE,
  asciicast_theme = if (Sys.getenv("IN_PKGDOWN") == "true") "pkgdown" else "readme"
)
Sys.setenv(CLI_TICK_TIME = "100")
asciicast::init_knitr_engine(
  startup = quote({
    library(cli)
    set.seed(1) }),
  echo = TRUE,
  echo_input = FALSE
)
```

> Helpers for Developing Command Line Interfaces


[![R-CMD-check](https://github.com/r-lib/cli/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/cli/actions/workflows/R-CMD-check.yaml)
[![](https://www.r-pkg.org/badges/version/cli)](https://www.r-pkg.org/pkg/cli)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/cli)](https://www.r-pkg.org/pkg/cli)
[![Codecov test coverage](https://codecov.io/gh/r-lib/cli/graph/badge.svg)](https://app.codecov.io/gh/r-lib/cli)


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.

---

# Features

* 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](https://github.com/tidyverse/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.

# Installation

Install the stable version from CRAN:

```r
install.packages("cli")
```

Install the development version from GitHub:

```r
pak::pak("r-lib/cli")
```

# Short tour

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

## Short alert messages

One liner messages to inform or warn.

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

```{asciicast alert-info}
db_url <- "example.com:port"
cli_alert_info("Reopened database {.url {db_url}}.")
```

```{asciicast alert-warning}
cli_alert_warning("Cannot reach GitHub, using local database cache.")
```

```{asciicast alert-danger}
cli_alert_danger("Failed to connect to database.")
```

```{asciicast alert}
cli_alert("A generic alert")
```

## Headings

Three levels of headings.

```{asciicast h1}
cli_h1("Heading 1")
```

```{asciicast h2}
cli_h2("Heading 2")
```

```{asciicast h3}
cli_h3("Heading 3")
```

## Lists

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

```{asciicast lists}
fun <- function() {
  cli_ol()
  cli_li("Item 1")
  ulid <- cli_ul()
  cli_li("Subitem 1")
  cli_li("Subitem 2")
  cli_end(ulid)
  cli_li("Item 2")
  cli_end()
}
fun()
```

## Themes

Theming via a CSS-like language.

```{asciicast themes}
fun <- function() {
  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()
```

## Command substitution

Automatic command substitution via the
[glue](https://github.com/tidyverse/glue) package.

```{asciicast glue}
size <- 123143123
dt <- 1.3454
cli_alert_info(c(
  "Downloaded {prettyunits::pretty_bytes(size)} in ",
  "{prettyunits::pretty_sec(dt)}"))
```

## Pluralization

Pluralization support.

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

## Progress bars

```{asciicast progress-setup, include = FALSE, cache = FALSE}
options(cli.progress_show_after = 0)
options(cli.progress_clear = FALSE)
```

```{asciicast progress}
#| asciicast_knitr_output = "svg",
#| asciicast_at = "all",
#| asciicast_cursor = FALSE
clean <- function() {
  cli_progress_bar("Cleaning data", total = 100)
  for (i in 1:100) {
    Sys.sleep(5/100)
    cli_progress_update()
  }
}
clean()
```

# Documentation

See at [`https://cli.r-lib.org/`](https://cli.r-lib.org/reference/index.html)
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](https://cli.r-lib.org/dev/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

# License

MIT © Posit Software, PBC

Owner

  • Name: R infrastructure
  • Login: r-lib
  • Kind: organization

GitHub Events

Total
  • Create event: 8
  • Release event: 2
  • Issues event: 52
  • Watch event: 28
  • Delete event: 8
  • Issue comment event: 93
  • Push event: 77
  • Pull request event: 34
  • Pull request review event: 13
  • Pull request review comment event: 20
  • Fork event: 4
Last Year
  • Create event: 8
  • Release event: 2
  • Issues event: 52
  • Watch event: 28
  • Delete event: 8
  • Issue comment event: 93
  • Push event: 77
  • Pull request event: 34
  • Pull request review event: 13
  • Pull request review comment event: 20
  • Fork event: 4

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,462
  • Total Committers: 48
  • Avg Commits per committer: 30.458
  • Development Distribution Score (DDS): 0.137
Past Year
  • Commits: 107
  • Committers: 12
  • Avg Commits per committer: 8.917
  • Development Distribution Score (DDS): 0.523
Top Committers
Name Email Commits
Gábor Csárdi c****r@g****m 1,261
Jenny Bryan j****n@g****m 42
Salim B g****t@s****e 25
hadley h****m@g****m 15
Kirill Müller k****r@m****g 14
Michael Chirico c****m@g****m 10
Romain Francois r****n@r****m 9
Lionel Henry l****y@g****m 8
olivroy 5****y 7
Colin Rundel r****l@g****m 6
Justin Mills j****s@f****v 6
Alex Rossell Hayes a****r@r****m 4
Tim Taylor t****r@h****k 4
Maximilian Muecke m****n@g****m 4
Indrajeet Patil p****e@g****m 4
Antoine Fabri a****i@g****m 3
DavisVaughan d****s@r****m 3
Jim Hester j****r@g****m 3
Taras Zakharko t****o@g****m 3
Jonathan Carroll j****o@j****u 2
tszberkowitz 6****z 2
Ben Bolker b****r@g****m 1
we we@e****m 1
Olivier Roy o****y@s****a 1
assignUser g****b@k****e 1
Zhian N. Kamvar z****r@g****m 1
Zachary Foster z****9@g****m 1
Simon P. Couch s****h@g****m 1
Shian Su c****b@g****m 1
Sebastian Jentschke 3****h 1
and 18 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 203
  • Total pull requests: 89
  • Average time to close issues: 2 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 103
  • Total pull request authors: 31
  • Average comments per issue: 2.01
  • Average comments per pull request: 1.4
  • Merged pull requests: 76
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 35
  • Pull requests: 27
  • Average time to close issues: 21 days
  • Average time to close pull requests: 28 days
  • Issue authors: 26
  • Pull request authors: 11
  • Average comments per issue: 0.86
  • Average comments per pull request: 1.48
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gaborcsardi (36)
  • olivroy (17)
  • hadley (14)
  • DanChaltiel (7)
  • MichaelChirico (5)
  • lionel- (4)
  • wurli (3)
  • DavisVaughan (3)
  • jennybc (3)
  • asadow (3)
  • salim-b (3)
  • simonpcouch (3)
  • wlandau (3)
  • DesiQuintans (2)
  • mkalamarz (2)
Pull Request Authors
  • gaborcsardi (18)
  • jennybc (15)
  • olivroy (12)
  • rundel (9)
  • salim-b (8)
  • m-muecke (6)
  • MichaelChirico (6)
  • TimTaylor (3)
  • mcol (3)
  • instantepiphany (2)
  • LouisMPenrod (2)
  • musvaage (2)
  • cynthiahqy (2)
  • ddsjoberg (2)
  • tszberkowitz (2)
Top Labels
Issue Labels
feature (33) bug (29) tidy-dev-day :nerd_face: (12) documentation (10) upkeep (10) help wanted :heart: (3) reprex (2) good first issue :heart: (2)
Pull Request Labels
feature (1)

Packages

  • Total packages: 3
  • Total downloads:
    • cran 1,285,158 last-month
  • Total docker downloads: 165,632,837
  • Total dependent packages: 764
    (may contain duplicates)
  • Total dependent repositories: 1,788
    (may contain duplicates)
  • Total versions: 74
  • Total maintainers: 1
cran.r-project.org: cli

Helpers for Developing Command Line Interfaces

  • Versions: 27
  • Dependent Packages: 683
  • Dependent Repositories: 1,697
  • Downloads: 1,285,158 Last month
  • Docker Downloads: 165,632,837
Rankings
Downloads: 0.0%
Dependent packages count: 0.2%
Dependent repos count: 0.2%
Stargazers count: 0.6%
Forks count: 1.1%
Average: 3.2%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/r-lib/cli
  • Versions: 27
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: r-cli
  • Versions: 20
  • Dependent Packages: 81
  • Dependent Repositories: 91
Rankings
Dependent packages count: 0.9%
Dependent repos count: 3.6%
Average: 11.8%
Stargazers count: 17.2%
Forks count: 25.2%
Last synced: 6 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.4 depends
  • utils * imports
  • callr * suggests
  • covr * suggests
  • crayon * suggests
  • digest * suggests
  • glue >= 1.6.0 suggests
  • grDevices * suggests
  • htmltools * suggests
  • htmlwidgets * suggests
  • knitr * suggests
  • methods * suggests
  • mockery * suggests
  • processx * suggests
  • ps >= 1.3.4.9000 suggests
  • rlang >= 1.0.2.9003 suggests
  • rmarkdown * suggests
  • rprojroot * suggests
  • rstudioapi * suggests
  • testthat * suggests
  • tibble * suggests
  • whoami * suggests
  • withr * suggests
tests/testthat/progresstest/DESCRIPTION cran
  • cli * imports
tests/testthat/progresstestcpp/DESCRIPTION cran
  • cli * imports
.github/workflows/rhub.yaml actions
  • actions/checkout v3 composite
  • r-hub/rhub2/actions/rhub-check v1 composite
  • r-hub/rhub2/actions/rhub-setup v1 composite
  • r-hub/rhub2/actions/rhub-setup-r v1 composite