From dd342c405901e7e182a71fcc6a4942907707dde8 Mon Sep 17 00:00:00 2001 From: David C Hall Date: Sun, 23 Oct 2022 09:44:09 -0700 Subject: [PATCH 01/67] Fix docs: remove duplicated item --- R/cliapp-docs.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 7bb924414..2f3953dc7 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -81,14 +81,11 @@ #' If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. #' See [links] for more about cli hyperlinks. -#' * `url` for a URL. -#' If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), -#' then cli creates a clickable link. -#' See [links] for more about cli hyperlinks. #' * `type` formats the type of an R object in a readable way, and it #' should be used with `{}`, see an example below. #' * `url` for a URL. If the terminal supports ANSI hyperlinks (e.g. #' RStudio, iTerm2, etc.), then cli creates a clickable link. +#' See [links] for more about cli hyperlinks. #' * `var` for a variable name. #' * `val` for a generic "value". #' * `vignette` is a vignette. From 0da32665674bc15bc9173ac06f045a4f3bc7a1de Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 25 Oct 2022 22:29:34 +0000 Subject: [PATCH 02/67] Fix typos --- R/cliapp-docs.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 2f3953dc7..f3a96fa32 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -55,11 +55,11 @@ #' the file in RStudio or with the default app for the file type. #' See [links] for more about cli hyperlinks. #' * `fun` for a function name. If it is in the `package::function_name` -#' form, and the the terminal supports ANSI hyperlinks (e.g. RStudio, +#' form, and the terminal supports ANSI hyperlinks (e.g. RStudio, #' iTerm2, etc.), then cli creates a clickable link. #' See [links] for more about cli hyperlinks. #' * `help` is a help page of a _function_. -#' If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. #' See [links] for more about cli hyperlinks. #' * `href` creates a hyperlink, potentially with a link text. @@ -78,7 +78,7 @@ #' It supports link text. See [links] for more about cli hyperlinks. #' * `strong` for strong importance. #' * `topic` is a help page of a _ropic_. -#' If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. #' See [links] for more about cli hyperlinks. #' * `type` formats the type of an R object in a readable way, and it @@ -89,7 +89,7 @@ #' * `var` for a variable name. #' * `val` for a generic "value". #' * `vignette` is a vignette. -#' If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +#' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. #' See [links] for more about cli hyperlinks. #' From d0a7186b5b71470cd97857d50d4669a601437b06 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 25 Oct 2022 22:31:51 +0000 Subject: [PATCH 03/67] Fix another typo --- R/cliapp-docs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index f3a96fa32..cb863ffb1 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -451,7 +451,7 @@ NULL #' #' # Link text #' -#' Before we delve into the various types of hyperlinks, a geneal comment +#' Before we delve into the various types of hyperlinks, a general comment #' about link texts. Some link styles support a custom link text: #' #' * `.href` From a8e2d0e34d73bd094316f136bcb56525531b5028 Mon Sep 17 00:00:00 2001 From: Salim B Date: Wed, 26 Oct 2022 22:05:15 +0000 Subject: [PATCH 04/67] Fix typo --- R/bullets.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bullets.R b/R/bullets.R index 10513b391..5d241e878 100644 --- a/R/bullets.R +++ b/R/bullets.R @@ -11,7 +11,7 @@ #' cli creates a `div` element of class `bullets` for the whole bullet list. #' Each item is another `div` element of class `bullet-`, where #' `` is the name of the entry in `text`. Entries in `text` without -#' a name create a `div` element of class `buller-empty`, and if the +#' a name create a `div` element of class `bullet-empty`, and if the #' name is a single space character, the class is `bullet-space`. #' #' The built-in theme defines the following item types: From 58c2b97ad37bef1f816c4834b6127879fb52fd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 2 Nov 2022 19:04:58 +0100 Subject: [PATCH 05/67] Add UTF-8 snapshot output For a tests with utf-8/ascii variants. --- tests/testthat/_snaps/utf8/utf8-output.txt | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/testthat/_snaps/utf8/utf8-output.txt diff --git a/tests/testthat/_snaps/utf8/utf8-output.txt b/tests/testthat/_snaps/utf8/utf8-output.txt new file mode 100644 index 000000000..f8c79e218 --- /dev/null +++ b/tests/testthat/_snaps/utf8/utf8-output.txt @@ -0,0 +1,55 @@ + +── Alerts ──────────────────────────────────────────────────────────── +→ マルチバイトのタイトル +✖ árvíztűrő tükörfúrógép +ℹ マルチバイトのタイトル +✔ マルチバイトのタイトル +! マルチバイトのタイトル + +── Block quote ─────────────────────────────────────────────────────── + + “マルチバイトのタイトル” + — árvíztűrő tükörfúrógép + +── Bullets ─────────────────────────────────────────────────────────── +• マルチバイトのタイトル +! árvíztűrő tükörfúrógép + +── Code ────────────────────────────────────────────────────────────── +マルチバイトのタイトル +árvíztűrő tükörfúrógép + +── Lists ───────────────────────────────────────────────────────────── +s1: マルチバイトのタイトル +s2: árvíztűrő tükörfúrógép +1. マルチバイトのタイトル +2. árvíztűrő tükörfúrógép +• マルチバイトのタイトル +• árvíztűrő tükörfúrógép + +── Headers ─────────────────────────────────────────────────────────── + +── マルチバイトのタイトル ──────────────────────────────────────────── + +── árvíztűrő tükörfúrógép ── + +── マルチバイトのタイトル + +── Progress bars ───────────────────────────────────────────────────── +ℹ マルチバイトのタイトル +✔ マルチバイトのタイトル [1s] + +ℹ árvíztűrő tükörfúrógép +✔ árvíztűrő tükörfúrógép [1s] + + +── Text ────────────────────────────────────────────────────────────── +マルチバイトのタイトル árvíztűrő tükörfúrógép マルチバイトのタイトル +árvíztűrő tükörfúrógép マルチバイトのタイトル マルチバイトのタイトル +マルチバイトのタイトル マルチバイトのタイトル árvíztűrő tükörfúrógép +マルチバイトのタイトル árvíztűrő tükörfúrógép マルチバイトのタイトル +マルチバイトのタイトル マルチバイトのタイトル マルチバイトのタイトル + +── Verbatim ────────────────────────────────────────────────────────── +マルチバイトのタイトル +árvíztűrő tükörfúrógép From 9dde5942abdb6452b85c64462ad9490418d5e1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 3 Nov 2022 10:06:00 +0100 Subject: [PATCH 06/67] document() --- man/cli_bullets.Rd | 2 +- man/inline-markup.Rd | 13 +++++-------- man/links.Rd | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/man/cli_bullets.Rd b/man/cli_bullets.Rd index 12e846878..252b0d397 100644 --- a/man/cli_bullets.Rd +++ b/man/cli_bullets.Rd @@ -26,7 +26,7 @@ Formatting is specified by the names of \code{text}, and can be themed. cli creates a \code{div} element of class \code{bullets} for the whole bullet list. Each item is another \code{div} element of class \verb{bullet-}, where \verb{} is the name of the entry in \code{text}. Entries in \code{text} without -a name create a \code{div} element of class \code{buller-empty}, and if the +a name create a \code{div} element of class \code{bullet-empty}, and if the name is a single space character, the class is \code{bullet-space}. The built-in theme defines the following item types: diff --git a/man/inline-markup.Rd b/man/inline-markup.Rd index f06175122..9b265e0d5 100644 --- a/man/inline-markup.Rd +++ b/man/inline-markup.Rd @@ -75,11 +75,11 @@ RStudio, iTerm2, etc.), then cli creates a clickable link that opens the file in RStudio or with the default app for the file type. See \link{links} for more about cli hyperlinks. \item \code{fun} for a function name. If it is in the \code{package::function_name} -form, and the the terminal supports ANSI hyperlinks (e.g. RStudio, +form, and the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. See \link{links} for more about cli hyperlinks. \item \code{help} is a help page of a \emph{function}. -If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. See \link{links} for more about cli hyperlinks. \item \code{href} creates a hyperlink, potentially with a link text. @@ -98,21 +98,18 @@ supports ANSI hyperlinks to runnable code (e.g. RStudio). It supports link text. See \link{links} for more about cli hyperlinks. \item \code{strong} for strong importance. \item \code{topic} is a help page of a \emph{ropic}. -If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. See \link{links} for more about cli hyperlinks. -\item \code{url} for a URL. -If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), -then cli creates a clickable link. -See \link{links} for more about cli hyperlinks. \item \code{type} formats the type of an R object in a readable way, and it should be used with \code{{}}, see an example below. \item \code{url} for a URL. If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. +See \link{links} for more about cli hyperlinks. \item \code{var} for a variable name. \item \code{val} for a generic "value". \item \code{vignette} is a vignette. -If the terminal supports ANSI hyperlinks to help paages (e.g. RStudio), +If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. See \link{links} for more about cli hyperlinks. } diff --git a/man/links.Rd b/man/links.Rd index 34cc79b61..73dff4966 100644 --- a/man/links.Rd +++ b/man/links.Rd @@ -35,7 +35,7 @@ terminal, please open a cli issue at } \section{Link text}{ -Before we delve into the various types of hyperlinks, a geneal comment +Before we delve into the various types of hyperlinks, a general comment about link texts. Some link styles support a custom link text: \itemize{ \item \code{.href} From 300795b35c012d758920f1e66ce5755535137a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 3 Nov 2022 14:14:20 +0100 Subject: [PATCH 07/67] Update GHA --- .github/workflows/R-CMD-check.yaml | 21 ++++++++++----------- .github/workflows/pkgdown.yaml | 17 ++++------------- .github/workflows/pr-commands.yaml | 5 ++--- .github/workflows/test-coverage.yaml | 24 +++++++++++++++++++++--- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5f555a7d4..ee65ccb57 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,27 +22,27 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - - {os: windows-2022, r: 'devel'} - {os: windows-latest, r: 'release'} # Use 3.6 to trigger usage of RTools35 - {os: windows-latest, r: '3.6'} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} - # Use older ubuntu to maximise backward compatibility - - {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-18.04, r: 'release'} - - {os: ubuntu-18.04, r: 'oldrel-1'} - - {os: ubuntu-18.04, r: 'oldrel-2'} - - {os: ubuntu-18.04, r: 'oldrel-3'} - - {os: ubuntu-18.04, r: 'oldrel-4'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 @@ -56,7 +56,6 @@ jobs: with: extra-packages: any::rcmdcheck needs: check - pak-version: rc - uses: r-lib/actions/check-r-package@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 0c995ebb8..087f0b05f 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -19,9 +19,8 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_CLI_NUM_COLORS: 256 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 @@ -31,24 +30,16 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: | - any::pkgdown - local::. - local::./tests/testthat/progresstest + extra-packages: any::pkgdown, local::. needs: website - pak-version: rc - name: Build site - run: | - rmarkdown::render("README.Rmd") - pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - env: - IN_PKGDOWN: true - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@4.1.4 + uses: JamesIves/github-pages-deploy-action@v4.4.1 with: clean: false branch: gh-pages diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index acfbf4050..71f335b3e 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -14,7 +14,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: @@ -28,7 +28,6 @@ jobs: with: extra-packages: any::roxygen2 needs: pr-document - pak-version: rc - name: Document run: roxygen2::roxygenise() @@ -52,7 +51,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 63ecc8bcc..2c5bb5029 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-r@v2 with: @@ -25,8 +25,26 @@ jobs: with: extra-packages: any::covr needs: coverage - pak-version: rc - name: Test coverage - run: covr::codecov(quiet = FALSE) + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + ) shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package From 96d4c9e400c3b8ff1119b478b4378eb00a8068e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 4 Nov 2022 12:11:28 +0100 Subject: [PATCH 08/67] New keypress() function (#540) --- NAMESPACE | 2 + NEWS.md | 2 + R/aab-rstudio-detect.R | 21 ++- R/keypress.R | 77 +++++++++ R/tty.R | 2 + _pkgdown.yml | 2 + man/has_keypress_support.Rd | 41 +++++ man/keypress.Rd | 43 +++++ src/init.c | 3 + src/keypress-unix.c | 268 ++++++++++++++++++++++++++++++ src/keypress-win.c | 130 +++++++++++++++ src/keypress.c | 86 ++++++++++ src/keypress.h | 84 ++++++++++ tests/testthat/_snaps/keypress.md | 126 ++++++++++++++ tests/testthat/helper.R | 28 ++++ tests/testthat/test-keypress.R | 61 +++++++ 16 files changed, 969 insertions(+), 7 deletions(-) create mode 100644 R/keypress.R create mode 100644 man/has_keypress_support.Rd create mode 100644 man/keypress.Rd create mode 100644 src/keypress-unix.c create mode 100644 src/keypress-win.c create mode 100644 src/keypress.c create mode 100644 src/keypress.h create mode 100644 tests/testthat/_snaps/keypress.md create mode 100644 tests/testthat/test-keypress.R diff --git a/NAMESPACE b/NAMESPACE index 5f4797a4f..692add20c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -166,6 +166,7 @@ export(format_inline) export(format_message) export(format_warning) export(get_spinner) +export(has_keypress_support) export(hash_animal) export(hash_emoji) export(hash_file_sha256) @@ -182,6 +183,7 @@ export(hash_sha256) export(is_ansi_tty) export(is_dynamic_tty) export(is_utf8_output) +export(keypress) export(list_border_styles) export(list_spinners) export(list_symbols) diff --git a/NEWS.md b/NEWS.md index 8aaac75ea..93b93ddee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # cli (development version) +* New `keypress()` function to read a single keypress from a terminal. + * New function `pretty_print_code()` to print function objects with syntax highlighting at the R console. diff --git a/R/aab-rstudio-detect.R b/R/aab-rstudio-detect.R index 87263d6c2..507e8bb4e 100644 --- a/R/aab-rstudio-detect.R +++ b/R/aab-rstudio-detect.R @@ -209,7 +209,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = FALSE, num_colors = 1L, - hyperlink = FALSE + hyperlink = FALSE, + has_canonical_mode = FALSE ) } @@ -220,7 +221,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = data$envs[["RSTUDIO_CONSOLE_COLOR"]] != "", num_colors = as.integer(data$envs[["RSTUDIO_CONSOLE_COLOR"]]), - hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "" + hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "", + has_canonical_mode = FALSE ) } @@ -237,7 +239,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = FALSE, num_colors = 1L, - hyperlink = FALSE + hyperlink = FALSE, + has_canonical_mode = FALSE ) } @@ -248,7 +251,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = data$envs[["RSTUDIO_CONSOLE_COLOR"]] != "", num_colors = as.integer(data$envs[["RSTUDIO_CONSOLE_COLOR"]]), - hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "" + hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "", + has_canonical_mode = FALSE ) } @@ -259,7 +263,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = data$envs[["RSTUDIO_CONSOLE_COLOR"]] != "", num_colors = as.integer(data$envs[["RSTUDIO_CONSOLE_COLOR"]]), - hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "" + hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "", + has_canonical_mode = FALSE ) } @@ -270,7 +275,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = FALSE, num_colors = 1L, - hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "" + hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "", + has_canonical_mode = FALSE ) } @@ -281,7 +287,8 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = FALSE, num_colors = 1L, - hyperlink = FALSE + hyperlink = FALSE, + has_canonical_mode = FALSE ) } diff --git a/R/keypress.R b/R/keypress.R new file mode 100644 index 000000000..bc0a4e2b0 --- /dev/null +++ b/R/keypress.R @@ -0,0 +1,77 @@ + +#' Read a single keypress at the terminal +#' +#' It currently only works at Linux/Unix and OSX terminals, +#' and at the Windows command line. see \code{\link{has_keypress_support}}. +#' +#' The following special keys are supported: +#' * Arrow keys: 'up', 'down', 'right', 'left'. +#' * Function keys: from 'f1' to 'f12'. +#' * Others: 'home', 'end', 'insert', 'delete', 'pageup', 'pagedown', +#' 'tab', 'enter', 'backspace' (same as 'delete' on OSX keyboards), +#' 'escape'. +#' * Control with one of the following keys: 'a', 'b', 'c', 'd', 'e', 'f', +#' 'h', 'k', 'l', 'n', 'p', 't', 'u', 'w'. +#' +#' @param block Whether to wait for a key press, if there is none +#' available now. +#' @return The key pressed, a character scalar. For non-blocking reads +#' `NA` is returned if no keys are available. +#' +#' @family keypress function +#' @export +#' @examplesIf FALSE +#' x <- keypress() +#' cat("You pressed key", x, "\n") + +keypress <- function(block = TRUE) { + if (!has_keypress_support()) { + stop("Your platform/terminal does not support `keypress()`.") + } + block <- as.logical(block) + if (length(block) != 1) stop("'block' must be a logical scalar") + ret <- .Call(cli_keypress, block) + if (ret == "none") NA_character_ else ret +} + +#' Check if the current platform/terminal supports reading +#' single keys. +#' +#' @details +#' Supported platforms: +#' * Terminals in Windows and Unix. +#' * RStudio terminal. +#' +#' Not supported: +#' * RStudio (if not in the RStudio terminal). +#' * R.app on macOS. +#' * Rgui on Windows. +#' * Emacs ESS. +#' * Others. +#' +#' @return Whether there is support for waiting for individual +#' keypressses. +#' +#' @family keypress function +#' @export +#' @examples +#' has_keypress_support() + +has_keypress_support <- function() { + ## Supported if we have a terminal or RStudio terminal. + ## Not supported otherwise in RStudio, R.app, Rgui or Emacs + + rs <- rstudio$detect() + + if (rs$type != "not_rstudio") { + rs$has_canonical_mode + + } else { + isatty(stdin()) && + Sys.getenv("R_GUI_APP_VERSION") == "" && + .Platform$GUI != "Rgui" && + ! identical(getOption("STERM"), "iESS") && + Sys.getenv("EMACS") != "t" && + Sys.getenv("TERM") != "dumb" + } +} diff --git a/R/tty.R b/R/tty.R index abc98c623..f0863734e 100644 --- a/R/tty.R +++ b/R/tty.R @@ -214,6 +214,7 @@ is_ansi_tty <- function(stream = "auto") { #' @export ansi_hide_cursor <- function(stream = "auto") { + if (Sys.getenv("R_CLI_HIDE_CURSOR") == "false") return() stream <- get_real_output(stream) if (is_ansi_tty(stream)) cat(ANSI_HIDE_CURSOR, file = stream) } @@ -222,6 +223,7 @@ ansi_hide_cursor <- function(stream = "auto") { #' @name ansi_hide_cursor ansi_show_cursor <- function(stream = "auto") { + if (Sys.getenv("R_CLI_HIDE_CURSOR") == "false") return() stream <- get_real_output(stream) if (is_ansi_tty(stream)) cat(ANSI_SHOW_CURSOR, file = stream) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 624c77e25..58112aab6 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -232,8 +232,10 @@ reference: - default_app - diff_chr - diff_str + - has_keypress_support - is_dynamic_tty - is_utf8_output + - keypress - ruler - start_app - stop_app diff --git a/man/has_keypress_support.Rd b/man/has_keypress_support.Rd new file mode 100644 index 000000000..08de2b75f --- /dev/null +++ b/man/has_keypress_support.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/keypress.R +\name{has_keypress_support} +\alias{has_keypress_support} +\title{Check if the current platform/terminal supports reading +single keys.} +\usage{ +has_keypress_support() +} +\value{ +Whether there is support for waiting for individual +keypressses. +} +\description{ +Check if the current platform/terminal supports reading +single keys. +} +\details{ +Supported platforms: +\itemize{ +\item Terminals in Windows and Unix. +\item RStudio terminal. +} + +Not supported: +\itemize{ +\item RStudio (if not in the RStudio terminal). +\item R.app on macOS. +\item Rgui on Windows. +\item Emacs ESS. +\item Others. +} +} +\examples{ +has_keypress_support() +} +\seealso{ +Other keypress function: +\code{\link{keypress}()} +} +\concept{keypress function} diff --git a/man/keypress.Rd b/man/keypress.Rd new file mode 100644 index 000000000..e1dd332e9 --- /dev/null +++ b/man/keypress.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/keypress.R +\name{keypress} +\alias{keypress} +\title{Read a single keypress at the terminal} +\usage{ +keypress(block = TRUE) +} +\arguments{ +\item{block}{Whether to wait for a key press, if there is none +available now.} +} +\value{ +The key pressed, a character scalar. For non-blocking reads +\code{NA} is returned if no keys are available. +} +\description{ +It currently only works at Linux/Unix and OSX terminals, +and at the Windows command line. see \code{\link{has_keypress_support}}. +} +\details{ +The following special keys are supported: +\itemize{ +\item Arrow keys: 'up', 'down', 'right', 'left'. +\item Function keys: from 'f1' to 'f12'. +\item Others: 'home', 'end', 'insert', 'delete', 'pageup', 'pagedown', +'tab', 'enter', 'backspace' (same as 'delete' on OSX keyboards), +'escape'. +\item Control with one of the following keys: 'a', 'b', 'c', 'd', 'e', 'f', +'h', 'k', 'l', 'n', 'p', 't', 'u', 'w'. +} +} +\examples{ +\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +x <- keypress() +cat("You pressed key", x, "\n") +\dontshow{\}) # examplesIf} +} +\seealso{ +Other keypress function: +\code{\link{has_keypress_support}()} +} +\concept{keypress function} diff --git a/src/init.c b/src/init.c index b6ffb7860..8b6972489 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,6 @@ #include "cli.h" +#include "keypress.h" #include "cleancall.h" #include @@ -77,6 +78,8 @@ static const R_CallMethodDef callMethods[] = { { "clic_vt_output", (DL_FUNC) clic_vt_output, 3 }, + { "cli_keypress", (DL_FUNC) cli_keypress, 1 }, + { NULL, NULL, 0 } }; diff --git a/src/keypress-unix.c b/src/keypress-unix.c new file mode 100644 index 000000000..980cab2f2 --- /dev/null +++ b/src/keypress-unix.c @@ -0,0 +1,268 @@ + +/* Avoid warning about empty compilation unit. */ +void keypress_unix_dummy(void) { } + +#ifndef _WIN32 + +#include "errors.h" +#include "keypress.h" +#include +#include +#include +#include + +keypress_key_t single_char(const char *buf) { + + int ch = buf[0]; + + switch(ch) { + case 1: return keypress_special(KEYPRESS_CTRL_A); + case 2: return keypress_special(KEYPRESS_CTRL_B); + case 3: return keypress_special(KEYPRESS_CTRL_C); + case 4: return keypress_special(KEYPRESS_CTRL_D); + case 5: return keypress_special(KEYPRESS_CTRL_E); + case 6: return keypress_special(KEYPRESS_CTRL_F); + case 8: return keypress_special(KEYPRESS_CTRL_H); + case 9: return keypress_special(KEYPRESS_TAB); + case 10: return keypress_special(KEYPRESS_ENTER); + case 11: return keypress_special(KEYPRESS_CTRL_K); + case 12: return keypress_special(KEYPRESS_CTRL_L); + case 13: return keypress_special(KEYPRESS_ENTER); + case 14: return keypress_special(KEYPRESS_CTRL_N); + case 16: return keypress_special(KEYPRESS_CTRL_P); + case 20: return keypress_special(KEYPRESS_CTRL_T); + case 21: return keypress_special(KEYPRESS_CTRL_U); + case 23: return keypress_special(KEYPRESS_CTRL_W); + case 27: return keypress_special(KEYPRESS_ESCAPE); + case 127: return keypress_special(KEYPRESS_BACKSPACE); + default : return keypress_utf8(buf); + } +} + +keypress_key_t function_key(const char *buf, size_t buf_size) { + buf++; /* escape character */ + buf_size -= 2; /* minus first escape and trailing zero */ + + /* xterm */ + if (! strncmp(buf, "[A", buf_size)) { + return keypress_special(KEYPRESS_UP); + } else if (!strncmp(buf, "[B", buf_size)) { + return keypress_special(KEYPRESS_DOWN); + } else if (!strncmp(buf, "[C", buf_size)) { + return keypress_special(KEYPRESS_RIGHT); + } else if (!strncmp(buf, "[D", buf_size)) { + return keypress_special(KEYPRESS_LEFT); + } else if (!strncmp(buf, "[F", buf_size)) { + return keypress_special(KEYPRESS_END); + } else if (!strncmp(buf, "[H", buf_size)) { + return keypress_special(KEYPRESS_HOME); + + /* xterm/gnome */ + } else if (!strncmp(buf, "OA", buf_size)) { + return keypress_special(KEYPRESS_UP); + } else if (!strncmp(buf, "OB", buf_size)) { + return keypress_special(KEYPRESS_DOWN); + } else if (!strncmp(buf, "OC", buf_size)) { + return keypress_special(KEYPRESS_RIGHT); + } else if (!strncmp(buf, "OD", buf_size)) { + return keypress_special(KEYPRESS_LEFT); + } else if (!strncmp(buf, "OF", buf_size)) { + return keypress_special(KEYPRESS_END); + } else if (!strncmp(buf, "OH", buf_size)) { + return keypress_special(KEYPRESS_HOME); + + /* xterm/rxvt */ + } else if (!strncmp(buf, "[1~", buf_size)) { + return keypress_special(KEYPRESS_HOME); + } else if (!strncmp(buf, "[2~", buf_size)) { + return keypress_special(KEYPRESS_INSERT); + } else if (!strncmp(buf, "[3~", buf_size)) { + return keypress_special(KEYPRESS_DELETE); + } else if (!strncmp(buf, "[4~", buf_size)) { + return keypress_special(KEYPRESS_END); + } else if (!strncmp(buf, "[5~", buf_size)) { + return keypress_special(KEYPRESS_PAGEUP); + } else if (!strncmp(buf, "[6~", buf_size)) { + return keypress_special(KEYPRESS_PAGEDOWN); + + /* putty */ + } else if (!strncmp(buf, "[[5~", buf_size)) { + return keypress_special(KEYPRESS_PAGEUP); + } else if (!strncmp(buf, "[[6~", buf_size)) { + return keypress_special(KEYPRESS_PAGEDOWN); + + /* rxvt */ + } else if (!strncmp(buf, "[[7~", buf_size)) { + return keypress_special(KEYPRESS_HOME); + } else if (!strncmp(buf, "[[8~", buf_size)) { + return keypress_special(KEYPRESS_END); + + /* xterm/gnome */ + } else if (!strncmp(buf, "OP", buf_size)) { + return keypress_special(KEYPRESS_F1); + } else if (!strncmp(buf, "OQ", buf_size)) { + return keypress_special(KEYPRESS_F2); + } else if (!strncmp(buf, "OR", buf_size)) { + return keypress_special(KEYPRESS_F3); + } else if (!strncmp(buf, "OS", buf_size)) { + return keypress_special(KEYPRESS_F4); + + /* common */ + } else if (!strncmp(buf, "[15~", buf_size)) { + return keypress_special(KEYPRESS_F5); + } else if (!strncmp(buf, "[17~", buf_size)) { + return keypress_special(KEYPRESS_F6); + } else if (!strncmp(buf, "[18~", buf_size)) { + return keypress_special(KEYPRESS_F7); + } else if (!strncmp(buf, "[19~", buf_size)) { + return keypress_special(KEYPRESS_F8); + } else if (!strncmp(buf, "[20~", buf_size)) { + return keypress_special(KEYPRESS_F9); + } else if (!strncmp(buf, "[21~", buf_size)) { + return keypress_special(KEYPRESS_F10); + } else if (!strncmp(buf, "[23~", buf_size)) { + return keypress_special(KEYPRESS_F11); + } else if (!strncmp(buf, "[24~", buf_size)) { + return keypress_special(KEYPRESS_F12); + + /* xterm / rxvt */ + } else if (!strncmp(buf, "[11~", buf_size)) { + return keypress_special(KEYPRESS_F1); + } else if (!strncmp(buf, "[12~", buf_size)) { + return keypress_special(KEYPRESS_F2); + } else if (!strncmp(buf, "[13~", buf_size)) { + return keypress_special(KEYPRESS_F3); + } else if (!strncmp(buf, "[14~", buf_size)) { + return keypress_special(KEYPRESS_F4); + + } else if (strlen(buf) == 0) { + return keypress_special(KEYPRESS_ESCAPE); + + } else { + return keypress_utf8(buf - 1); + } + + return keypress_special(KEYPRESS_UNKNOWN); +} + +keypress_key_t keypress_read(int block) { + + char buf[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + struct termios term = { 0 }; + int flags = fcntl(0, F_GETFL, 0); + + if (tcgetattr(0, &term) < 0) { + R_THROW_SYSTEM_ERROR("Cannot query terminal flags"); + } + + tcflag_t term_flags = term.c_lflag; + int term_vmin = term.c_cc[VMIN]; + int term_vtime = term.c_cc[VTIME]; + + term.c_lflag &= ~ICANON; + term.c_lflag &= ~ECHO; + term.c_cc[VMIN] = 1; + term.c_cc[VTIME] = 0; + + if (tcsetattr(0, TCSANOW, &term) < 0) { + R_THROW_SYSTEM_ERROR("Cannot set canonical mode"); + } + + if (! block) { + if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) { + R_THROW_SYSTEM_ERROR("Cannot set terminal to non-blocking"); + } + } + + if (read(0, buf, 1) < 0) { + if (fcntl(0, F_SETFL, flags) == -1) { + R_THROW_SYSTEM_ERROR("Cannot set terminal flags"); + } + term.c_lflag = term_flags; + term.c_cc[VMIN] = term_vmin; + term.c_cc[VTIME] = term_vtime; + tcsetattr(0, TCSADRAIN, &term); + + if (block) { + R_THROW_SYSTEM_ERROR("Cannot read key"); + } else { + return keypress_special(KEYPRESS_NONE); + } + } + + /* If an escape sequence, then we read the rest. + We cannot read everything in one go, because of + copy-and-paste. This way for a copy-and-paste + we only read the first character. */ + + if (buf[0] == '\033') { + /* At least two more characters are needed. We do a non-blocking + read to detect if the user only pressed ESC */ + ssize_t chars = 0; + if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) { + R_THROW_SYSTEM_ERROR("Cannot set terminal flags"); + } + chars = read(0, buf + 1, 2); + if (fcntl(0, F_SETFL, flags) == -1) { + R_THROW_SYSTEM_ERROR("Cannot set terminal flags"); + } + if (chars == 2 && buf[1] == '[' && buf[2] >= '1' && buf[2] <= '6') { + /* A third one is needed, too */ + if (read(0, buf + 3, 1) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + if (buf[3] >= '0' && buf[3] <= '9') { + /* A fourth one is needed, too */ + if (read(0, buf + 4, 1) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + } + } else if (chars == 2 && buf[1] == '[' && buf[2] == '[') { + /* Two more is needed if it starts with [[ */ + if (read(0, buf + 3, 2) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + } + } + + /* For UTF8 characters, we might need to read more bytes + We don't handle errors here, if there are not enough bytes + to read, we'll just return whatever is available. */ + if ((buf[0] & 0x80) == 0) { + /* Nothing to do */ + } else if ((buf[0] & 0xe0) == 0xc0) { + if (read(0, &buf[1], 1) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + } else if ((buf[0] & 0xf0) == 0xe0) { + if (read(0, &buf[1], 2) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + } else if ((buf[0] & 0xf8) == 0xf0) { + if (read(0, &buf[1], 3) < 0) { + R_THROW_SYSTEM_ERROR("Cannot read from terminal"); + } + } + + if (fcntl(0, F_SETFL, flags) == -1) { + R_THROW_SYSTEM_ERROR("Cannot set terminal flags"); + } + + term.c_lflag = term_flags; + term.c_cc[VMIN] = term_vmin; + term.c_cc[VTIME] = term_vtime; + + if (tcsetattr(0, TCSADRAIN, &term) < 0) { + R_THROW_SYSTEM_ERROR("Cannot reset terminal flags"); + } + + if (buf[0] == '\033') { + /* Some excape sequence */ + return function_key(buf, sizeof(buf)); + } else { + /* Single character */ + return single_char(buf); + } +} + +#endif diff --git a/src/keypress-win.c b/src/keypress-win.c new file mode 100644 index 000000000..52a714e0e --- /dev/null +++ b/src/keypress-win.c @@ -0,0 +1,130 @@ + +/* Avoid warning about empty compilation unit. */ +void keypress_win_dummy(void) { } + +#ifdef WIN32 + +#include "errors.h" +#include "keypress.h" +#include + +static HANDLE console_in, console_out; + +static int enableRawMode(void) { + if (!console_in) { + HANDLE hin, hout; + hin = GetStdHandle(STD_INPUT_HANDLE); + if (hin == INVALID_HANDLE_VALUE) { + R_THROW_SYSTEM_ERROR("Cannot get standard input handle"); + } + hout = GetStdHandle(STD_OUTPUT_HANDLE); + if (hout == INVALID_HANDLE_VALUE) { + R_THROW_SYSTEM_ERROR("Cannot get standard output handle"); + } + console_in = hin; + console_out = hout; + } + return 0; +} + +static int disableRawMode(void) { + /* Nothing to do yet */ + return 0; +} + +keypress_key_t getWinChar(int block) { + INPUT_RECORD rec; + DWORD count; + char buf[2] = { 0, 0 }; + int chr; + + for (;; Sleep(10)) { + + GetNumberOfConsoleInputEvents(console_in, &count); + + if ((count == 0) && (block == NON_BLOCKING)) { + return keypress_special(KEYPRESS_NONE); + } + + if (! ReadConsoleInputA(console_in, &rec, 1, &count)) { + R_THROW_SYSTEM_ERROR("Cannot read from console"); + } + if (rec.EventType != KEY_EVENT) continue; + if (! rec.Event.KeyEvent.bKeyDown) continue; + buf[0] = chr = rec.Event.KeyEvent.uChar.AsciiChar; + + switch (rec.Event.KeyEvent.wVirtualKeyCode) { + + case VK_RETURN: return keypress_special(KEYPRESS_ENTER); + case VK_BACK: return keypress_special(KEYPRESS_BACKSPACE); + case VK_LEFT: return keypress_special(KEYPRESS_LEFT); + case VK_RIGHT: return keypress_special(KEYPRESS_RIGHT); + case VK_UP: return keypress_special(KEYPRESS_UP); + case VK_DOWN: return keypress_special(KEYPRESS_DOWN); + case VK_INSERT: return keypress_special(KEYPRESS_INSERT); + case VK_DELETE: return keypress_special(KEYPRESS_DELETE); + case VK_HOME: return keypress_special(KEYPRESS_HOME); + case VK_END: return keypress_special(KEYPRESS_END); + case VK_ESCAPE: return keypress_special(KEYPRESS_ESCAPE); + + case VK_F1: return keypress_special(KEYPRESS_F1); + case VK_F2: return keypress_special(KEYPRESS_F2); + case VK_F3: return keypress_special(KEYPRESS_F3); + case VK_F4: return keypress_special(KEYPRESS_F4); + case VK_F5: return keypress_special(KEYPRESS_F5); + case VK_F6: return keypress_special(KEYPRESS_F6); + case VK_F7: return keypress_special(KEYPRESS_F7); + case VK_F8: return keypress_special(KEYPRESS_F8); + case VK_F9: return keypress_special(KEYPRESS_F9); + case VK_F10: return keypress_special(KEYPRESS_F10); + case VK_F11: return keypress_special(KEYPRESS_F11); + case VK_F12: return keypress_special(KEYPRESS_F12); + + default: + if (rec.Event.KeyEvent.dwControlKeyState & + (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { + switch (chr) { + case 1: return keypress_special(KEYPRESS_CTRL_A); + case 2: return keypress_special(KEYPRESS_CTRL_B); + case 3: return keypress_special(KEYPRESS_CTRL_C); + case 4: return keypress_special(KEYPRESS_CTRL_D); + case 5: return keypress_special(KEYPRESS_CTRL_E); + case 6: return keypress_special(KEYPRESS_CTRL_F); + case 8: return keypress_special(KEYPRESS_CTRL_H); + case 9: return keypress_special(KEYPRESS_TAB); + case 11: return keypress_special(KEYPRESS_CTRL_K); + case 12: return keypress_special(KEYPRESS_CTRL_L); + case 14: return keypress_special(KEYPRESS_CTRL_N); + case 16: return keypress_special(KEYPRESS_CTRL_P); + case 20: return keypress_special(KEYPRESS_CTRL_T); + case 21: return keypress_special(KEYPRESS_CTRL_U); + case 22: return keypress_special(KEYPRESS_CTRL_W); + } + } else if (buf[0]) { + return keypress_utf8(buf); + } + } + + } +} + +keypress_key_t keypress_read(int block) { + + keypress_key_t res; + + CONSOLE_SCREEN_BUFFER_INFO inf; + + enableRawMode(); + + if (! GetConsoleScreenBufferInfo(console_out, &inf)) { + R_THROW_SYSTEM_ERROR("Cannot query console information"); + } + + res = getWinChar(block); + + disableRawMode(); + + return res; +} + +#endif diff --git a/src/keypress.c b/src/keypress.c new file mode 100644 index 000000000..543af8d5e --- /dev/null +++ b/src/keypress.c @@ -0,0 +1,86 @@ + +#include "keypress.h" + +const char *keypress_key_names[KEYPRESS_NAME_SIZE] = { + "", /* 0 */ + + "enter", /* 1 */ + "backspace", /* 2 */ + "left", /* 3 */ + "right", /* 4 */ + "up", /* 5 */ + "down", /* 6 */ + "insert", /* 7 */ + "delete", /* 8 */ + "home", /* 9 */ + "end", /* 10 */ + + "f1", /* 11 */ + "f2", /* 12 */ + "f3", /* 13 */ + "f4", /* 14 */ + "f5", /* 15 */ + "f6", /* 16 */ + "f7", /* 17 */ + "f8", /* 18 */ + "f9", /* 19 */ + "f10", /* 20 */ + "f11", /* 21 */ + "f12", /* 22 */ + + "ctrl-a", /* 23 */ + "ctrl-b", /* 24 */ + "ctrl-c", /* 25 */ + "ctrl-d", /* 26 */ + "ctrl-e", /* 27 */ + "ctrl-f", /* 28 */ + "ctrl-h", /* 29 */ + "ctrl-k", /* 30 */ + "ctrl-l", /* 31 */ + "ctrl-n", /* 32 */ + "ctrl-p", /* 33 */ + "ctrl-t", /* 34 */ + "ctrl-u", /* 35 */ + "ctrl-w", /* 36 */ + + "escape", /* 37 */ + "tab", /* 38 */ + + "pageup", /* 39 */ + "pagedown", /* 40 */ + + "none", /* 41 */ + + "unknown" /* 42 */ +}; + +keypress_key_t keypress_special(int key) { + keypress_key_t result; + result.code = key; + result.ascii = '0'; + result.utf8[0] = '0'; + return result; +} + +keypress_key_t keypress_utf8(const char *buf) { + keypress_key_t result; + result.code = KEYPRESS_CHAR; + result.ascii = '0'; + strncpy(result.utf8, buf, KEYPRESS_UTF8_BUFFER_SIZE); + result.utf8[KEYPRESS_UTF8_BUFFER_SIZE] = '0'; + return result; +} + +SEXP cli_keypress(SEXP s_block) { + SEXP result = NULL; + int block = LOGICAL(s_block)[0]; + keypress_key_t key = keypress_read(block); + + if (key.code == KEYPRESS_CHAR) { + return ScalarString(mkCharCE(key.utf8, CE_UTF8)); + } else { + return ScalarString(mkCharCE(keypress_key_names[key.code], CE_UTF8)); + } + + return result; +} diff --git a/src/keypress.h b/src/keypress.h new file mode 100644 index 000000000..0b49c1199 --- /dev/null +++ b/src/keypress.h @@ -0,0 +1,84 @@ + +#ifndef KEYPRESS_H +#define KEYPRESS_H + +#include +#include + +#define BLOCKING 1 +#define NON_BLOCKING 0 + +#define KEYPRESS_CHAR 0 + +#define KEYPRESS_ENTER 1 +#define KEYPRESS_BACKSPACE 2 +#define KEYPRESS_LEFT 3 +#define KEYPRESS_RIGHT 4 +#define KEYPRESS_UP 5 +#define KEYPRESS_DOWN 6 +#define KEYPRESS_INSERT 7 +#define KEYPRESS_DELETE 8 +#define KEYPRESS_HOME 9 +#define KEYPRESS_END 10 + +#define KEYPRESS_F1 11 +#define KEYPRESS_F2 12 +#define KEYPRESS_F3 13 +#define KEYPRESS_F4 14 +#define KEYPRESS_F5 15 +#define KEYPRESS_F6 16 +#define KEYPRESS_F7 17 +#define KEYPRESS_F8 18 +#define KEYPRESS_F9 19 +#define KEYPRESS_F10 20 +#define KEYPRESS_F11 21 +#define KEYPRESS_F12 22 + +#define KEYPRESS_CTRL_A 23 +#define KEYPRESS_CTRL_B 24 +#define KEYPRESS_CTRL_C 25 +#define KEYPRESS_CTRL_D 26 +#define KEYPRESS_CTRL_E 27 +#define KEYPRESS_CTRL_F 28 +#define KEYPRESS_CTRL_H 29 +#define KEYPRESS_CTRL_K 30 +#define KEYPRESS_CTRL_L 31 +#define KEYPRESS_CTRL_N 32 +#define KEYPRESS_CTRL_P 33 +#define KEYPRESS_CTRL_T 34 +#define KEYPRESS_CTRL_U 35 +#define KEYPRESS_CTRL_W 36 + +#define KEYPRESS_ESCAPE 37 +#define KEYPRESS_TAB 38 + +#define KEYPRESS_PAGEUP 39 +#define KEYPRESS_PAGEDOWN 40 + +/* Nothing read, for non-blocking reads */ +#define KEYPRESS_NONE 41 + +/* Something, e.g. escape seq, but don't know what exactly */ +#define KEYPRESS_UNKNOWN 42 + +#define KEYPRESS_NAME_SIZE 43 + +/* The longest UTF8 character in bytes */ +#define KEYPRESS_UTF8_BUFFER_SIZE 4 + +typedef struct { + int code; + char ascii; + char utf8[KEYPRESS_UTF8_BUFFER_SIZE + 1]; +} keypress_key_t; + +keypress_key_t keypress_read(int block); + +keypress_key_t keypress_special(int key); +keypress_key_t keypress_utf8(const char *buf); + +SEXP cli_keypress(SEXP s_block); + +extern const char *keypress_key_names[KEYPRESS_NAME_SIZE]; + +#endif diff --git a/tests/testthat/_snaps/keypress.md b/tests/testthat/_snaps/keypress.md new file mode 100644 index 000000000..82a746ec6 --- /dev/null +++ b/tests/testthat/_snaps/keypress.md @@ -0,0 +1,126 @@ +# control characaters + + Code + for (code in c(1:2, 4:6, 8:14, 16L, 20L, 21L, 23L, 27L, 127L)) { + p$write_input("cli::keypress()\n") + Sys.sleep(0.1) + p$write_input(as.raw(code)) + p$poll_io(1000) + cat(p$read_output()) + } + Output + [1] "ctrl-a" + [1] "ctrl-b" + [1] "ctrl-d" + [1] "ctrl-e" + [1] "ctrl-f" + [1] "ctrl-h" + [1] "tab" + [1] "enter" + [1] "ctrl-k" + [1] "ctrl-l" + [1] "enter" + [1] "ctrl-n" + [1] "ctrl-p" + [1] "ctrl-t" + [1] "ctrl-u" + [1] "ctrl-w" + [1] "escape" + [1] "backspace" + +# write ahead + + Code + p$write_input("{ Sys.sleep(0.5); cli::keypress() }\nX") + p$poll_io(1000) + Output + output error process + "ready" "nopipe" "silent" + Code + cat(p$read_output()) + Output + [1] "X" + +# arrows, etc + + Code + for (key in keys) { + p$write_input("cli::keypress()\n") + p$write_input(key) + p$poll_io(1000) + cat(p$read_output()) + } + Output + [1] "up" + [1] "right" + [1] "left" + [1] "end" + [1] "home" + [1] "-" + [1] "up" + [1] "down" + [1] "right" + [1] "left" + [1] "end" + [1] "home" + [1] "-" + [1] "home" + [1] "insert" + [1] "delete" + [1] "end" + [1] "pageup" + [1] "pagedown" + [1] "-" + [1] "pageup" + [1] "pagedown" + [1] "-" + [1] "home" + [1] "end" + [1] "-" + [1] "f1" + [1] "f2" + [1] "f3" + [1] "f4" + [1] "-" + [1] "f5" + [1] "f6" + [1] "f7" + [1] "f8" + [1] "f9" + [1] "f10" + [1] "f11" + [1] "f12" + [1] "-" + [1] "f1" + [1] "f2" + [1] "f3" + [1] "f4" + [1] "-" + [1] "escape" + +# nonblocking + + Code + p$write_input("cli::keypress(block = FALSE)\n") + p$poll_io(1000) + Output + output error process + "ready" "nopipe" "silent" + Code + cat(p$read_output()) + Output + [1] NA + +--- + + Code + p$write_input("{ Sys.sleep(0.5); cli::keypress() }\nX") + p$poll_io(1000) + Output + output error process + "ready" "nopipe" "silent" + Code + cat(p$read_output()) + Output + [1] "X" + diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 844e5c35f..77f879974 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -194,3 +194,31 @@ sanitize_srcref <- function(x) { sanitize_call <- function(x) { gsub(" in `.*`", "", x) } + +r_pty <- function(.envir = parent.frame()) { + skip_on_cran() + # TODO: why does this fail on the CI, in covr + if (Sys.getenv("R_COVR") == "true" && + isTRUE(as.logical(Sys.getenv("CI")))) { + skip("fails on CI in covr") + } + if (!Sys.info()[["sysname"]] %in% c("Darwin", "Linux")) skip("Needs Linux or macOS") + + r <- file.path(R.home("bin"), "R") + p <- processx::process$new( + r, + c("-q", "--slave", "--vanilla"), + pty = TRUE, + env = c("current", R_CLI_HIDE_CURSOR = "false", R_LIBS = .libPaths()[1]) + ) + + defer({ + close(p$get_input_connection()) + p$wait(1000) + p$kill() + }, envir = .envir) + + p$poll_io(1000) + p$read_output() + p +} diff --git a/tests/testthat/test-keypress.R b/tests/testthat/test-keypress.R new file mode 100644 index 000000000..d609f4f37 --- /dev/null +++ b/tests/testthat/test-keypress.R @@ -0,0 +1,61 @@ + +test_that("control characaters", { + p <- r_pty() + + expect_snapshot( + for (code in c(1:2, 4:6, 8:14, 16L, 20L, 21L, 23L, 27L, 127L)) { + p$write_input("cli::keypress()\n") + Sys.sleep(0.1) + p$write_input(as.raw(code)) + p$poll_io(1000) + cat(p$read_output()) + } + ) +}) + +test_that("write ahead", { + p <- r_pty() + expect_snapshot({ + p$write_input("{ Sys.sleep(0.5); cli::keypress() }\nX") + p$poll_io(1000) + cat(p$read_output()) + }) +}) + +test_that("arrows, etc", { + p <- r_pty() + keys <- paste0("\033", c( + "[A", "[C", "[D", "[F", "[H", "-", + "OA", "OB", "OC", "OD", "OF", "OH", "-", + "[1~", "[2~", "[3~", "[4~", "[5~", "[6~", "-", + "[[5~", "[[6~", "-", + "[[7~", "[[8~", "-", + "OP", "OQ", "OR", "OS", "-", + "[15~", "[17~", "[18~", "[19~", "[20~", "[21~", "[23~", "[24~", "-", + "[11~", "[12~", "[13~", "[14~", "-", + "" + )) + keys[keys == "\033-"] <- "-" + expect_snapshot({ + for (key in keys) { + p$write_input("cli::keypress()\n") + p$write_input(key) + p$poll_io(1000) + cat(p$read_output()) + } + }) +}) + +test_that("nonblocking", { + p <- r_pty() + expect_snapshot({ + p$write_input("cli::keypress(block = FALSE)\n") + p$poll_io(1000) + cat(p$read_output()) + }) + expect_snapshot({ + p$write_input("{ Sys.sleep(0.5); cli::keypress() }\nX") + p$poll_io(1000) + cat(p$read_output()) + }) +}) From 5454fcb32b5fd1568a15eedcc5b6a145546efb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 9 Nov 2022 09:55:12 +0100 Subject: [PATCH 09/67] New `hash_file_md5()` function, MD5 hash of files --- NAMESPACE | 1 + NEWS.md | 3 +++ R/hash.R | 17 +++++++++++++ man/hash_md5.Rd | 8 ++++++ src/cli.h | 1 + src/init.c | 1 + src/md5.c | 51 ++++++++++++++++++++++++++++++++++++++ tests/testthat/test-hash.R | 15 +++++++++++ 8 files changed, 97 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 692add20c..9c8b5633f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -169,6 +169,7 @@ export(get_spinner) export(has_keypress_support) export(hash_animal) export(hash_emoji) +export(hash_file_md5) export(hash_file_sha256) export(hash_md5) export(hash_obj_animal) diff --git a/NEWS.md b/NEWS.md index 93b93ddee..087e9f8e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,9 @@ * `ansi_strtrim()` now handles some edge cases better, when `ellipsis` has length zero, and when it is wider than `width`. +* New `hash_file_md5()` function to calculate the MD5 hash of one or more + files. + # cli 3.4.1 * cli has better error messages now. diff --git a/R/hash.R b/R/hash.R index 6923338de..591a482b9 100644 --- a/R/hash.R +++ b/R/hash.R @@ -121,6 +121,23 @@ hash_obj_md5 <- function(x, serialize_version = 2) { hash_raw_md5(sr) } +#' @export +#' @rdname hash_md5 +#' @param paths Character vector of file names. +#' @details `hash_file_md5()` calcultaes the MD5 hash of one of more +#' files. + +hash_file_md5 <- function(paths) { + if (!is.character(paths)) paths <- as.character(paths) + paths <- normalizePath(paths, mustWork = FALSE) + if (is_windows()) { + paths <- enc2utf8(paths) + } else { + paths <- enc2native(paths) + } + .Call(clic_md5_file, paths) +} + #' Emoji hash #' #' @details diff --git a/man/hash_md5.Rd b/man/hash_md5.Rd index bc09b31bc..eeb7b65d9 100644 --- a/man/hash_md5.Rd +++ b/man/hash_md5.Rd @@ -4,6 +4,7 @@ \alias{hash_md5} \alias{hash_raw_md5} \alias{hash_obj_md5} +\alias{hash_file_md5} \title{MD5 hash} \usage{ hash_md5(x) @@ -11,6 +12,8 @@ hash_md5(x) hash_raw_md5(x) hash_obj_md5(x, serialize_version = 2) + +hash_file_md5(paths) } \arguments{ \item{x}{Character vector. If not a character vector, then @@ -19,6 +22,8 @@ will have an \code{NA} hash.} \item{serialize_version}{Workspace format version to use, see \code{\link[base:serialize]{base::serialize()}}.} + +\item{paths}{Character vector of file names.} } \value{ \code{hash_md5()} returns a character vector of hexadecimal MD5 @@ -37,6 +42,9 @@ of a raw vector. \code{hash_obj_md5()} calculates the MD5 hash of an R object. The object is serialized into a binary vector first. + +\code{hash_file_md5()} calcultaes the MD5 hash of one of more +files. } \examples{ hash_md5(c("foo", NA, "bar", "")) diff --git a/src/cli.h b/src/cli.h index 3b4bae5fb..50212fb96 100644 --- a/src/cli.h +++ b/src/cli.h @@ -13,6 +13,7 @@ SEXP clic_diff_chr(SEXP a, SEXP b, SEXP max); SEXP clic_getppid(void); SEXP clic_md5(SEXP strs); SEXP clic_md5_raw(SEXP r); +SEXP clic_md5_file(SEXP paths); SEXP clic_sha256(SEXP strs); SEXP clic_sha256_raw(SEXP r); SEXP clic_sha256_file(SEXP paths); diff --git a/src/init.c b/src/init.c index 8b6972489..d85484c51 100644 --- a/src/init.c +++ b/src/init.c @@ -37,6 +37,7 @@ static const R_CallMethodDef callMethods[] = { { "clic_getppid", (DL_FUNC) clic_getppid, 0 }, { "clic_md5", (DL_FUNC) clic_md5, 1 }, { "clic_md5_raw", (DL_FUNC) clic_md5_raw, 1 }, + { "clic_md5_file", (DL_FUNC) clic_md5_file, 1 }, { "clic_sha256", (DL_FUNC) clic_sha256, 1 }, { "clic_sha256_raw", (DL_FUNC) clic_sha256_raw, 1 }, { "clic_sha256_file", (DL_FUNC) clic_sha256_file, 1 }, diff --git a/src/md5.c b/src/md5.c index fd0602d34..0c82f3b2f 100644 --- a/src/md5.c +++ b/src/md5.c @@ -6,9 +6,13 @@ #include "md5.h" #include "errors.h" +#include "winfiles.h" #include +#include +#include + static void bin2str(char *to, const unsigned char *p, size_t len) { static const char *hex = "0123456789abcdef"; for (; len--; p++) { @@ -68,3 +72,50 @@ SEXP clic_md5_raw(SEXP r) { CE_UTF8 )); } + +SEXP clic_md5_file(SEXP paths) { + md5_byte_t hash[16]; + char hexhash[32]; + md5_state_t ctx; + R_xlen_t i, len = XLENGTH(paths); +#define BUFSIZE (1 * 1024*1024) + char *buffer = R_alloc(1, BUFSIZE); + SEXP result = PROTECT(Rf_allocVector(STRSXP, len)); + + for (i = 0; i < len; i++) { + const char *cpath = CHAR(STRING_ELT(paths, i)); + int fd = open_file(cpath, O_RDONLY); + if (fd == -1) { + R_THROW_SYSTEM_ERROR("Cannot open file `%s`", cpath); + } + md5_init(&ctx); + + ssize_t got = read(fd, buffer, BUFSIZE); + if (got == -1) { + close(fd); + R_THROW_SYSTEM_ERROR("Cannot read from file `%s`", cpath); + } + + while (got > 0) { + md5_append(&ctx, (const md5_byte_t*) buffer, got); + got = read(fd, buffer, BUFSIZE); + if (got == -1) { + close(fd); + R_THROW_SYSTEM_ERROR("Cannot read from file `%s`", cpath); + } + } + + close(fd); + + md5_finish(&ctx, hash); + bin2str(hexhash, hash, sizeof(hash)); + SET_STRING_ELT( + result, + i, + Rf_mkCharLenCE((const char*) hexhash, sizeof(hexhash), CE_UTF8) + ); + } + + UNPROTECT(1); + return result; +} diff --git a/tests/testthat/test-hash.R b/tests/testthat/test-hash.R index 76236c7c8..d14041230 100644 --- a/tests/testthat/test-hash.R +++ b/tests/testthat/test-hash.R @@ -123,6 +123,21 @@ test_that("hash_obj_md5", { } }) +test_that("hash_file_md5", { + dig <- function(x) { + digest::digest(file = x, algo = "md5") + } + + f <- test_path("test-hash.R") + expect_equal( + hash_file_md5(character()), + character() + ) + + expect_equal(hash_file_md5(f), dig(f)) + expect_equal(hash_file_md5(c(f, f)), c(dig(f), dig(f))) +}) + test_that("hash_emoji", { expect_snapshot({ hash_emoji(character())$names From 30e12dc6cc87186cb936c7a7aa92143c313eeec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sun, 13 Nov 2022 14:24:38 +0100 Subject: [PATCH 10/67] No show-cursor ANSI seq in task cb & finalizer if env var If `R_CLI_HIDE_CURSOR` is set to `false` then cli does not register a task callback and a finalizer to show the cursor. This is to make the output more predictable in test cases. --- R/onload.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/onload.R b/R/onload.R index 68f04aaec..b0279943f 100644 --- a/R/onload.R +++ b/R/onload.R @@ -31,7 +31,7 @@ rstudio_r_fix <- 0 err$onload_hook() # Try to restore cursor as much as we can - if (isatty(stdout())) { + if (Sys.getenv("R_CLI_HIDE_CURSOR") != "false" && isatty(stdout())) { reg.finalizer(clienv, function(e) cli::ansi_show_cursor(), TRUE) task_callback <<- addTaskCallback( function(...) { cli::ansi_show_cursor(); TRUE }, From 18d9f82fb536ade9bdd6f718f7f837a590722568 Mon Sep 17 00:00:00 2001 From: George Stagg Date: Tue, 15 Nov 2022 09:46:49 +0000 Subject: [PATCH 11/67] Compatibility with webR --- src/thread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thread.c b/src/thread.c index 04521fdcf..431af440a 100644 --- a/src/thread.c +++ b/src/thread.c @@ -47,6 +47,9 @@ int cli__start_thread(SEXP ticktime, SEXP speedtime) { cli__tick_ts.tv_nsec = (cticktime % 1000) * 1000 * 1000; int ret = 0; +#ifdef __EMSCRIPTEN__ + cli__reset = 0; +#else if (! getenv("CLI_NO_THREAD")) { ret = pthread_create( & tick_thread, @@ -63,6 +66,7 @@ int cli__start_thread(SEXP ticktime, SEXP speedtime) { } else { cli__reset = 0; } +#endif return ret; } From fa90b06bb90dff077622ef047d92218a6129271c Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Thu, 17 Nov 2022 16:53:57 +0100 Subject: [PATCH 12/67] Support hidden visibility --- src/Makevars | 1 + src/init.c | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 src/Makevars diff --git a/src/Makevars b/src/Makevars new file mode 100644 index 000000000..bf5eb423f --- /dev/null +++ b/src/Makevars @@ -0,0 +1 @@ +PKG_CFLAGS = $(C_VISIBILITY) diff --git a/src/init.c b/src/init.c index d85484c51..2ca1f6d6b 100644 --- a/src/init.c +++ b/src/init.c @@ -6,6 +6,11 @@ #include #include +// Compile with `C_VISIBILITY = -fvisibility=hidden` if you link to +// this library +#include +#define r_export attribute_visible extern + SEXP clic_unload(void) { clic_stop_thread(); return R_NilValue; @@ -86,6 +91,7 @@ static const R_CallMethodDef callMethods[] = { #define RCC(fun) R_RegisterCCallable("cli", # fun, (DL_FUNC) fun); +r_export void R_init_cli(DllInfo *dll) { #if R_VERSION >= R_Version(3, 5, 0) cli_init_altrep(dll); From 7e0cfa8e86e8d657f5660a13c85e1f7a452d2c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 3 Dec 2022 15:58:44 +0100 Subject: [PATCH 13/67] README in light/dark mode (#546) --- .github/workflows/pkgdown.yaml | 5 +- README.Rmd | 2 +- README.md | 69 ++++++++++++++++------- man/figures/README/alert-danger-dark.svg | 1 + man/figures/README/alert-danger.svg | 2 +- man/figures/README/alert-dark.svg | 1 + man/figures/README/alert-info-dark.svg | 1 + man/figures/README/alert-info.svg | 2 +- man/figures/README/alert-success-dark.svg | 1 + man/figures/README/alert-success.svg | 2 +- man/figures/README/alert-warning-dark.svg | 1 + man/figures/README/alert-warning.svg | 2 +- man/figures/README/alert.svg | 2 +- man/figures/README/glue-dark.svg | 1 + man/figures/README/glue.svg | 2 +- man/figures/README/h1-dark.svg | 1 + man/figures/README/h1.svg | 2 +- man/figures/README/h2-dark.svg | 1 + man/figures/README/h2.svg | 2 +- man/figures/README/h3-dark.svg | 1 + man/figures/README/h3.svg | 2 +- man/figures/README/lists-dark.svg | 1 + man/figures/README/lists.svg | 2 +- man/figures/README/plurals-dark.svg | 1 + man/figures/README/plurals.svg | 2 +- man/figures/README/progress-dark.svg | 1 + man/figures/README/progress.svg | 2 +- man/figures/README/themes-dark.svg | 1 + man/figures/README/themes.svg | 2 +- 29 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 man/figures/README/alert-danger-dark.svg create mode 100644 man/figures/README/alert-dark.svg create mode 100644 man/figures/README/alert-info-dark.svg create mode 100644 man/figures/README/alert-success-dark.svg create mode 100644 man/figures/README/alert-warning-dark.svg create mode 100644 man/figures/README/glue-dark.svg create mode 100644 man/figures/README/h1-dark.svg create mode 100644 man/figures/README/h2-dark.svg create mode 100644 man/figures/README/h3-dark.svg create mode 100644 man/figures/README/lists-dark.svg create mode 100644 man/figures/README/plurals-dark.svg create mode 100644 man/figures/README/progress-dark.svg create mode 100644 man/figures/README/themes-dark.svg diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 087f0b05f..2f6189fce 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -30,7 +30,10 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::pkgdown, local::. + extra-packages: | + any::pkgdown + local::. + local::./tests/testthat/progresstest needs: website - name: Build site diff --git a/README.Rmd b/README.Rmd index 472b88878..597a977e3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -14,7 +14,7 @@ knitr::opts_chunk$set( fig.path = "man/figures/README", out.width = "100%", cache = TRUE, - asciicast_theme = "pkgdown" + asciicast_theme = if (Sys.getenv("IN_PKGDOWN") == "true") "pkgdown" else "readme" ) Sys.setenv(CLI_TICK_TIME = "100") asciicast::init_knitr_engine( diff --git a/README.md b/README.md index 3b904d7d4..35565e8fd 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,16 @@ 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. +- 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 @@ -58,32 +58,45 @@ pkgs <- c("foo", "bar", "foobar") cli_alert_success("Downloaded {length(pkgs)} packages.") ``` + + + ``` r db_url <- "example.com:port" cli_alert_info("Reopened database {.url {db_url}}.") ``` - + + + ``` r cli_alert_warning("Cannot reach GitHub, using local database cache.") ``` + + + ``` r cli_alert_danger("Failed to connect to database.") ``` + + + ``` r cli_alert("A generic alert") ``` - + + + ## Headings @@ -93,19 +106,25 @@ Three levels of headings. cli_h1("Heading 1") ``` - + + + ``` r cli_h2("Heading 2") ``` - + + + ``` r cli_h3("Heading 3") ``` - + + + ## Lists @@ -125,7 +144,9 @@ fun <- function() { fun() ``` - + + + ## Themes @@ -141,7 +162,9 @@ fun <- function() { fun() ``` - + + + ## Command substitution @@ -156,7 +179,9 @@ cli_alert_info(c( "{prettyunits::pretty_sec(dt)}")) ``` - + + + ## Pluralization @@ -168,7 +193,9 @@ ndirs <- 1 cli_alert_info("Found {nfiles} file{?s} and {ndirs} director{?y/ies}.") ``` - + + + ## Progress bars @@ -183,7 +210,9 @@ clean <- function() { clean() ``` - + + + # Documentation diff --git a/man/figures/README/alert-danger-dark.svg b/man/figures/README/alert-danger-dark.svg new file mode 100644 index 000000000..2bad4360f --- /dev/null +++ b/man/figures/README/alert-danger-dark.svg @@ -0,0 +1 @@ +Failedtoconnecttodatabase. \ No newline at end of file diff --git a/man/figures/README/alert-danger.svg b/man/figures/README/alert-danger.svg index f0cf8bdc7..ad0219697 100644 --- a/man/figures/README/alert-danger.svg +++ b/man/figures/README/alert-danger.svg @@ -1 +1 @@ -Failedtoconnecttodatabase. \ No newline at end of file +Failedtoconnecttodatabase. \ No newline at end of file diff --git a/man/figures/README/alert-dark.svg b/man/figures/README/alert-dark.svg new file mode 100644 index 000000000..ef4b83150 --- /dev/null +++ b/man/figures/README/alert-dark.svg @@ -0,0 +1 @@ +Agenericalert \ No newline at end of file diff --git a/man/figures/README/alert-info-dark.svg b/man/figures/README/alert-info-dark.svg new file mode 100644 index 000000000..6e5421ac3 --- /dev/null +++ b/man/figures/README/alert-info-dark.svg @@ -0,0 +1 @@ +Reopeneddatabase<example.com:port>. \ No newline at end of file diff --git a/man/figures/README/alert-info.svg b/man/figures/README/alert-info.svg index f542c3a05..a24d26fc9 100644 --- a/man/figures/README/alert-info.svg +++ b/man/figures/README/alert-info.svg @@ -1 +1 @@ -Reopeneddatabase<example.com:port>. \ No newline at end of file +Reopeneddatabase<example.com:port>. \ No newline at end of file diff --git a/man/figures/README/alert-success-dark.svg b/man/figures/README/alert-success-dark.svg new file mode 100644 index 000000000..07b041b7c --- /dev/null +++ b/man/figures/README/alert-success-dark.svg @@ -0,0 +1 @@ +Downloaded3packages. \ No newline at end of file diff --git a/man/figures/README/alert-success.svg b/man/figures/README/alert-success.svg index 773579633..ea40bf913 100644 --- a/man/figures/README/alert-success.svg +++ b/man/figures/README/alert-success.svg @@ -1 +1 @@ -Downloaded3packages. \ No newline at end of file +Downloaded3packages. \ No newline at end of file diff --git a/man/figures/README/alert-warning-dark.svg b/man/figures/README/alert-warning-dark.svg new file mode 100644 index 000000000..2f646fe15 --- /dev/null +++ b/man/figures/README/alert-warning-dark.svg @@ -0,0 +1 @@ +!CannotreachGitHub,usinglocaldatabasecache. \ No newline at end of file diff --git a/man/figures/README/alert-warning.svg b/man/figures/README/alert-warning.svg index 54651bdfd..3c2f4e3f3 100644 --- a/man/figures/README/alert-warning.svg +++ b/man/figures/README/alert-warning.svg @@ -1 +1 @@ -!CannotreachGitHub,usinglocaldatabasecache. \ No newline at end of file +!CannotreachGitHub,usinglocaldatabasecache. \ No newline at end of file diff --git a/man/figures/README/alert.svg b/man/figures/README/alert.svg index 4591b1d79..ccf443306 100644 --- a/man/figures/README/alert.svg +++ b/man/figures/README/alert.svg @@ -1 +1 @@ -Agenericalert \ No newline at end of file +Agenericalert \ No newline at end of file diff --git a/man/figures/README/glue-dark.svg b/man/figures/README/glue-dark.svg new file mode 100644 index 000000000..a9e9a7472 --- /dev/null +++ b/man/figures/README/glue-dark.svg @@ -0,0 +1 @@ +Downloaded123.14MBin1.3s \ No newline at end of file diff --git a/man/figures/README/glue.svg b/man/figures/README/glue.svg index d0960e911..e3ae04a63 100644 --- a/man/figures/README/glue.svg +++ b/man/figures/README/glue.svg @@ -1 +1 @@ -Downloaded123.14MBin1.3s \ No newline at end of file +Downloaded123.14MBin1.3s \ No newline at end of file diff --git a/man/figures/README/h1-dark.svg b/man/figures/README/h1-dark.svg new file mode 100644 index 000000000..fdf89f16d --- /dev/null +++ b/man/figures/README/h1-dark.svg @@ -0,0 +1 @@ +──Heading1─────────────────────────────────────────────────────────────────── \ No newline at end of file diff --git a/man/figures/README/h1.svg b/man/figures/README/h1.svg index 22f226538..c87c61264 100644 --- a/man/figures/README/h1.svg +++ b/man/figures/README/h1.svg @@ -1 +1 @@ -──Heading1─────────────────────────────────────────────────────────────────── \ No newline at end of file +──Heading1─────────────────────────────────────────────────────────────────── \ No newline at end of file diff --git a/man/figures/README/h2-dark.svg b/man/figures/README/h2-dark.svg new file mode 100644 index 000000000..19d934b9f --- /dev/null +++ b/man/figures/README/h2-dark.svg @@ -0,0 +1 @@ +──Heading2── \ No newline at end of file diff --git a/man/figures/README/h2.svg b/man/figures/README/h2.svg index b47239532..83ddd2e8f 100644 --- a/man/figures/README/h2.svg +++ b/man/figures/README/h2.svg @@ -1 +1 @@ -──Heading2── \ No newline at end of file +──Heading2── \ No newline at end of file diff --git a/man/figures/README/h3-dark.svg b/man/figures/README/h3-dark.svg new file mode 100644 index 000000000..4350e52dd --- /dev/null +++ b/man/figures/README/h3-dark.svg @@ -0,0 +1 @@ +──Heading3 \ No newline at end of file diff --git a/man/figures/README/h3.svg b/man/figures/README/h3.svg index e5b42ad91..b44c52f2e 100644 --- a/man/figures/README/h3.svg +++ b/man/figures/README/h3.svg @@ -1 +1 @@ -──Heading3 \ No newline at end of file +──Heading3 \ No newline at end of file diff --git a/man/figures/README/lists-dark.svg b/man/figures/README/lists-dark.svg new file mode 100644 index 000000000..a3e511161 --- /dev/null +++ b/man/figures/README/lists-dark.svg @@ -0,0 +1 @@ +1.Item1Subitem1Subitem22.Item2 \ No newline at end of file diff --git a/man/figures/README/lists.svg b/man/figures/README/lists.svg index 86246434b..4ba4666d7 100644 --- a/man/figures/README/lists.svg +++ b/man/figures/README/lists.svg @@ -1 +1 @@ -1.Item1Subitem1Subitem22.Item2 \ No newline at end of file +1.Item1Subitem1Subitem22.Item2 \ No newline at end of file diff --git a/man/figures/README/plurals-dark.svg b/man/figures/README/plurals-dark.svg new file mode 100644 index 000000000..32513e5f7 --- /dev/null +++ b/man/figures/README/plurals-dark.svg @@ -0,0 +1 @@ +Found3filesand1directory. \ No newline at end of file diff --git a/man/figures/README/plurals.svg b/man/figures/README/plurals.svg index 8f60bd7c4..bbbddb809 100644 --- a/man/figures/README/plurals.svg +++ b/man/figures/README/plurals.svg @@ -1 +1 @@ -Found3filesand1directory. \ No newline at end of file +Found3filesand1directory. \ No newline at end of file diff --git a/man/figures/README/progress-dark.svg b/man/figures/README/progress-dark.svg new file mode 100644 index 000000000..1bb007f71 --- /dev/null +++ b/man/figures/README/progress-dark.svg @@ -0,0 +1 @@ +Cleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sCleaningdata1%|ETA:6sCleaningdata■■2%|ETA:6sCleaningdata■■4%|ETA:6sCleaningdata■■■5%|ETA:6sCleaningdata■■■6%|ETA:6sCleaningdata■■■8%|ETA:6sCleaningdata■■■■10%|ETA:6sCleaningdata■■■■11%|ETA:6sCleaningdata■■■■■13%|ETA:6sCleaningdata■■■■■14%|ETA:6sCleaningdata■■■■■■16%|ETA:6sCleaningdata■■■■■■17%|ETA:6sCleaningdata■■■■■■■19%|ETA:5sCleaningdata■■■■■■■21%|ETA:5sCleaningdata■■■■■■■■22%|ETA:5sCleaningdata■■■■■■■■24%|ETA:5sCleaningdata■■■■■■■■■25%|ETA:5sCleaningdata■■■■■■■■■27%|ETA:5sCleaningdata■■■■■■■■■28%|ETA:5sCleaningdata■■■■■■■■■■29%|ETA:5sCleaningdata■■■■■■■■■■31%|ETA:5sCleaningdata■■■■■■■■■■■32%|ETA:5sCleaningdata■■■■■■■■■■■34%|ETA:4sCleaningdata■■■■■■■■■■■35%|ETA:4sCleaningdata■■■■■■■■■■■■37%|ETA:4sCleaningdata■■■■■■■■■■■■■39%|ETA:4sCleaningdata■■■■■■■■■■■■■40%|ETA:4sCleaningdata■■■■■■■■■■■■■■42%|ETA:4sCleaningdata■■■■■■■■■■■■■■43%|ETA:4sCleaningdata■■■■■■■■■■■■■■■45%|ETA:4sCleaningdata■■■■■■■■■■■■■■■46%|ETA:4sCleaningdata■■■■■■■■■■■■■■■48%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■50%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■51%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■53%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■54%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■56%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■57%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■59%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■60%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■■62%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■■63%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■65%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■66%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■68%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■69%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■70%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■72%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■74%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■75%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■77%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■78%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■80%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■81%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■83%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■84%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■86%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■87%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■89%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■91%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■92%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■94%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■95%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■97%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■98%|ETA:0s \ No newline at end of file diff --git a/man/figures/README/progress.svg b/man/figures/README/progress.svg index 86b0c6fdf..27ff21158 100644 --- a/man/figures/README/progress.svg +++ b/man/figures/README/progress.svg @@ -1 +1 @@ -Cleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sCleaningdata1%|ETA:5sCleaningdata■■2%|ETA:6sCleaningdata■■4%|ETA:6sCleaningdata■■■6%|ETA:6sCleaningdata■■■8%|ETA:5sCleaningdata■■■■10%|ETA:5sCleaningdata■■■■11%|ETA:5sCleaningdata■■■■■13%|ETA:5sCleaningdata■■■■■15%|ETA:5sCleaningdata■■■■■■16%|ETA:5sCleaningdata■■■■■■18%|ETA:5sCleaningdata■■■■■■■19%|ETA:5sCleaningdata■■■■■■■21%|ETA:5sCleaningdata■■■■■■■■23%|ETA:5sCleaningdata■■■■■■■■■25%|ETA:5sCleaningdata■■■■■■■■■26%|ETA:4sCleaningdata■■■■■■■■■28%|ETA:4sCleaningdata■■■■■■■■■■30%|ETA:4sCleaningdata■■■■■■■■■■■32%|ETA:4sCleaningdata■■■■■■■■■■■33%|ETA:4sCleaningdata■■■■■■■■■■■35%|ETA:4sCleaningdata■■■■■■■■■■■■37%|ETA:4sCleaningdata■■■■■■■■■■■■■39%|ETA:4sCleaningdata■■■■■■■■■■■■■40%|ETA:4sCleaningdata■■■■■■■■■■■■■■42%|ETA:3sCleaningdata■■■■■■■■■■■■■■44%|ETA:3sCleaningdata■■■■■■■■■■■■■■■46%|ETA:3sCleaningdata■■■■■■■■■■■■■■■47%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■49%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■51%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■53%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■54%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■56%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■58%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■59%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■61%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■63%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■64%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■66%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■68%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■70%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■71%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■73%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■75%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■77%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■78%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■80%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■82%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■84%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■85%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■87%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■89%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■90%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■92%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■94%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■96%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■97%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■99%|ETA:0s \ No newline at end of file +Cleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sCleaningdata1%|ETA:6sCleaningdata■■2%|ETA:6sCleaningdata■■4%|ETA:6sCleaningdata■■■5%|ETA:6sCleaningdata■■■6%|ETA:6sCleaningdata■■■8%|ETA:6sCleaningdata■■■■10%|ETA:6sCleaningdata■■■■11%|ETA:6sCleaningdata■■■■■13%|ETA:6sCleaningdata■■■■■14%|ETA:6sCleaningdata■■■■■■16%|ETA:6sCleaningdata■■■■■■17%|ETA:6sCleaningdata■■■■■■■19%|ETA:5sCleaningdata■■■■■■■21%|ETA:5sCleaningdata■■■■■■■■22%|ETA:5sCleaningdata■■■■■■■■24%|ETA:5sCleaningdata■■■■■■■■■25%|ETA:5sCleaningdata■■■■■■■■■27%|ETA:5sCleaningdata■■■■■■■■■28%|ETA:5sCleaningdata■■■■■■■■■■29%|ETA:5sCleaningdata■■■■■■■■■■31%|ETA:5sCleaningdata■■■■■■■■■■■32%|ETA:5sCleaningdata■■■■■■■■■■■34%|ETA:4sCleaningdata■■■■■■■■■■■35%|ETA:4sCleaningdata■■■■■■■■■■■■37%|ETA:4sCleaningdata■■■■■■■■■■■■■39%|ETA:4sCleaningdata■■■■■■■■■■■■■40%|ETA:4sCleaningdata■■■■■■■■■■■■■■42%|ETA:4sCleaningdata■■■■■■■■■■■■■■43%|ETA:4sCleaningdata■■■■■■■■■■■■■■■45%|ETA:4sCleaningdata■■■■■■■■■■■■■■■46%|ETA:4sCleaningdata■■■■■■■■■■■■■■■48%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■50%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■51%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■53%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■54%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■56%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■57%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■59%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■60%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■■62%|ETA:3sCleaningdata■■■■■■■■■■■■■■■■■■■■63%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■65%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■66%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■68%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■69%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■70%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■72%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■74%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■75%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■77%|ETA:2sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■78%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■80%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■81%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■83%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■84%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■86%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■87%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■89%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■91%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■92%|ETA:1sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■94%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■95%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■97%|ETA:0sCleaningdata■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■98%|ETA:0s \ No newline at end of file diff --git a/man/figures/README/themes-dark.svg b/man/figures/README/themes-dark.svg new file mode 100644 index 000000000..1cf348da7 --- /dev/null +++ b/man/figures/README/themes-dark.svg @@ -0,0 +1 @@ +ThisisveryimportantBacktotheprevioustheme \ No newline at end of file diff --git a/man/figures/README/themes.svg b/man/figures/README/themes.svg index c2a228d05..4a7882997 100644 --- a/man/figures/README/themes.svg +++ b/man/figures/README/themes.svg @@ -1 +1 @@ -ThisisveryimportantBacktotheprevioustheme \ No newline at end of file +ThisisveryimportantBacktotheprevioustheme \ No newline at end of file From c61e538416e870412108ce51c6c0bbcc3720454e Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 16 Dec 2022 16:35:44 -0500 Subject: [PATCH 14/67] add prettyunits to `Config/Needs/website` (#549) Closes https://github.com/r-lib/cli/issues/548 --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index c0214eb9f..7307f84cb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -50,6 +50,7 @@ Config/Needs/website: decor, desc, fansi, + prettyunits, sessioninfo, tidyverse/tidytemplate, usethis, From 5b1eecb2ed64ed5b8c893f90060a3604684a8da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 20 Dec 2022 09:45:25 +0100 Subject: [PATCH 15/67] Polish NEWS [ci skip] --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 087e9f8e9..429735dab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # cli (development version) -* New `keypress()` function to read a single keypress from a terminal. +* New `keypress()` function to read a single key press from a terminal. * New function `pretty_print_code()` to print function objects with syntax highlighting at the R console. From 28b7a8fdbd9c17ca051c2f51e41c030ad4004ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 20 Dec 2022 09:53:12 +0100 Subject: [PATCH 16/67] Fix URL redirect [ci skip] --- R/progress-server.R | 2 +- man/cli_progress_builtin_handlers.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/progress-server.R b/R/progress-server.R index 41fc1e376..e1a6c61d7 100644 --- a/R/progress-server.R +++ b/R/progress-server.R @@ -42,7 +42,7 @@ #' #' ### `rstudio` #' -#' Use [RStudio's job panel](https://www.rstudio.com/blog/rstudio-1-2-jobs/) +#' Use [RStudio's job panel](https://posit.co/blog/rstudio-1-2-jobs/) #' to show the progress bars. This handler is available at the RStudio console, #' in recent versions of RStudio. #' diff --git a/man/cli_progress_builtin_handlers.Rd b/man/cli_progress_builtin_handlers.Rd index 5992d1a59..86ffb63de 100644 --- a/man/cli_progress_builtin_handlers.Rd +++ b/man/cli_progress_builtin_handlers.Rd @@ -54,7 +54,7 @@ progress bars. This handler is always able to handle all progress bars. \subsection{\code{rstudio}}{ -Use \href{https://www.rstudio.com/blog/rstudio-1-2-jobs/}{RStudio's job panel} +Use \href{https://posit.co/blog/rstudio-1-2-jobs/}{RStudio's job panel} to show the progress bars. This handler is available at the RStudio console, in recent versions of RStudio. } From 2f023b277fdd63b302fb078460b6ff2d225d6e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 20 Dec 2022 12:47:23 +0100 Subject: [PATCH 17/67] Increment version number to 3.5.0 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7307f84cb..ad3bf1a36 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.4.1.9000 +Version: 3.5.0 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 429735dab..9110abca8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cli (development version) +# cli 3.5.0 * New `keypress()` function to read a single key press from a terminal. From 449d2450451a624903c48658aaa24a5ae805decf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 20 Dec 2022 15:27:35 +0100 Subject: [PATCH 18/67] Increment version number to 3.5.0.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ad3bf1a36..04846192a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.5.0 +Version: 3.5.0.9000 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 9110abca8..dea949bd4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# cli (development version) + # cli 3.5.0 * New `keypress()` function to read a single key press from a terminal. From 8b0ce749f92039055aa729148a8cb47c56691b18 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 20 Dec 2022 19:58:24 +0000 Subject: [PATCH 19/67] Fix doc (#552) --- R/glue.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/glue.R b/R/glue.R index 8cb627d38..0d479edac 100644 --- a/R/glue.R +++ b/R/glue.R @@ -61,6 +61,7 @@ drop_null <- function(x) { #' Collapse a vector into a string scalar #' +#' @description #' Features: #' #' - custom separator, @@ -69,23 +70,23 @@ drop_null <- function(x) { #' - uses Unicode ellipsis character on UTF-8 console, #' - can collapse "from both ends", with `style = "both-ends"`, #' - can consider a limit for the display width of the result, in characters, -#' - handles ANSI control sequences correctly when measuring dipaly width. +#' - handles ANSI control sequences correctly when measuring display width. #' #' @param x Character vector, or an object with an `as.character()` method #' to collapse. #' @param sep Character string, separator. #' @param last Last separator, if there is no truncation. E.g. use #' `", and "` for the Oxford comma. -#' @param trunc MAximum number of elements to show. For `sytle = "head"` +#' @param trunc Maximum number of elements to show. For `style = "head"` #' at least `trunc = 1` is used. For `style = "both-ends"` at least #' `trunc = 5` is used, even if a smaller number is specified. #' @param width Limit for the display width of the result, in characters. #' This is a hard limit, and the output will never exceed it. #' This argument is not implemented for the `"both-ends"` style, which #' always uses `Inf`, with a warning if a fininte `width` value is set. -#' @param ellipsis character string to use at the place of the truncation. -#' By default the Unicode ellipsis character is used if the console is -#' UTF-8 and three dots otherwise. +#' @param ellipsis Character string to use at the place of the truncation. +#' By default, the Unicode ellipsis character is used if the console is +#' UTF-8, and three dots otherwise. #' @param style Truncation style: #' * `both-ends`: the default, shows the beginning and end of the vector, #' and skips elements in the middle if needed. @@ -94,7 +95,7 @@ drop_null <- function(x) { #' @return Character scalar. It is `NA_character_` if any elements in the #' vector are `NA`. #' -#' @seealso `glue_collapse` in the glue package incpired this function +#' @seealso `glue_collapse` in the glue package inspired this function #' @export #' @examples #' ansi_collapse(letters) From e792797a1be8b965b0f8d556478e531da7ca9fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 21 Dec 2022 14:26:39 +0100 Subject: [PATCH 20/67] hash_*sha1() functions to calculate SHA-1 hashes (#551) --- NAMESPACE | 4 + NEWS.md | 3 + R/hash.R | 70 +++++++++++ _pkgdown.yml | 1 + man/hash_animal.Rd | 1 + man/hash_emoji.Rd | 1 + man/hash_md5.Rd | 1 + man/hash_sha1.Rd | 62 ++++++++++ man/hash_sha256.Rd | 3 +- src/cli.h | 3 + src/init.c | 3 + src/sha1.c | 302 +++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 man/hash_sha1.Rd create mode 100644 src/sha1.c diff --git a/NAMESPACE b/NAMESPACE index 9c8b5633f..85473ed4c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -170,16 +170,20 @@ export(has_keypress_support) export(hash_animal) export(hash_emoji) export(hash_file_md5) +export(hash_file_sha1) export(hash_file_sha256) export(hash_md5) export(hash_obj_animal) export(hash_obj_emoji) export(hash_obj_md5) +export(hash_obj_sha1) export(hash_obj_sha256) export(hash_raw_animal) export(hash_raw_emoji) export(hash_raw_md5) +export(hash_raw_sha1) export(hash_raw_sha256) +export(hash_sha1) export(hash_sha256) export(is_ansi_tty) export(is_dynamic_tty) diff --git a/NEWS.md b/NEWS.md index dea949bd4..a9aaebb76 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # cli (development version) +* New `hash_*sha1()` functions to calculate the SHA-1 hash of strings, + objects, files. + # cli 3.5.0 * New `keypress()` function to read a single key press from a terminal. diff --git a/R/hash.R b/R/hash.R index 591a482b9..a8c43f7fe 100644 --- a/R/hash.R +++ b/R/hash.R @@ -69,6 +69,76 @@ hash_file_sha256 <- function(paths) { .Call(clic_sha256_file, paths) } +#' SHA-1 hash +#' +#' Calculate the SHA-1 hash of each element of a character vector. +#' +#' @param x Character vector. If not a character vector, then +#' [as.character()] is used to try to coerce it into one. `NA` entries +#' will have an `NA` hash. +#' @return `hash_sha1()` returns aharacter vector of hexadecimal +#' SHA-1 hashes. + +#' @family hash functions +#' +#' @export +#' @examples +#' hash_sha1(c("foo", NA, "bar", "")) + +hash_sha1 <- function(x) { + if (!is.character(x)) x <- as.character(x) + na <- is.na(x) + x[na] <- NA_character_ + x[!na] <- .Call(clic_sha1, x[!na]) + x +} + +#' @export +#' @rdname hash_sha1 +#' @details `hash_raw_sha1()` calculates the SHA-1 hash of the bytes +#' of a raw vector. +#' +#' @return `hash_raw_sha1()` returns a character scalar. + +hash_raw_sha1 <- function(x) { + stopifnot(is.raw(x)) + .Call(clic_sha1_raw, x) +} + +#' @export +#' @rdname hash_sha1 +#' @param serialize_version Workspace format version to use, see +#' [base::serialize()]. +#' @details `hash_obj_sha1()` calculates the SHA-1 hash of an R +#' object. The object is serialized into a binary vector first. +#' +#' @return `hash_obj_sha1()` returns a character scalar. + +hash_obj_sha1 <- function(x, serialize_version = 2) { + sr <- serialize(x, NULL, version = serialize_version)[-(1:14)] + hash_raw_sha1(sr) +} + +#' @export +#' @rdname hash_sha1 +#' @param paths Character vector of file names. +#' @details `hash_file_sha1()` calculates the SHA-1 hash of one or +#' more files. +#' +#' @return `hash_file_sha1()` returns a character vector of SHA-1 +#' hashes. + +hash_file_sha1 <- function(paths) { + if (!is.character(paths)) paths <- as.character(paths) + paths <- normalizePath(paths, mustWork = FALSE) + if (is_windows()) { + paths <- enc2utf8(paths) + } else { + paths <- enc2native(paths) + } + .Call(clic_sha1_file, paths) +} + #' MD5 hash #' #' Calculate the MD5 hash of each element of a character vector. diff --git a/_pkgdown.yml b/_pkgdown.yml index 58112aab6..6490c0997 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -213,6 +213,7 @@ reference: - hash_animal - hash_emoji - hash_md5 + - hash_sha1 - hash_sha256 - title: Utilities and Configuration diff --git a/man/hash_animal.Rd b/man/hash_animal.Rd index 4fdd3316b..81f2fb7ea 100644 --- a/man/hash_animal.Rd +++ b/man/hash_animal.Rd @@ -85,6 +85,7 @@ the ids package for generating random adjective-animal ids Other hash functions: \code{\link{hash_emoji}()}, \code{\link{hash_md5}()}, +\code{\link{hash_sha1}()}, \code{\link{hash_sha256}()} } \concept{hash functions} diff --git a/man/hash_emoji.Rd b/man/hash_emoji.Rd index 508dd317e..c1494e0e3 100644 --- a/man/hash_emoji.Rd +++ b/man/hash_emoji.Rd @@ -83,6 +83,7 @@ the emoji package for a comprehensive list of emojis Other hash functions: \code{\link{hash_animal}()}, \code{\link{hash_md5}()}, +\code{\link{hash_sha1}()}, \code{\link{hash_sha256}()} } \concept{hash functions} diff --git a/man/hash_md5.Rd b/man/hash_md5.Rd index eeb7b65d9..686fe6ff7 100644 --- a/man/hash_md5.Rd +++ b/man/hash_md5.Rd @@ -56,6 +56,7 @@ files. Other hash functions: \code{\link{hash_animal}()}, \code{\link{hash_emoji}()}, +\code{\link{hash_sha1}()}, \code{\link{hash_sha256}()} } \concept{hash functions} diff --git a/man/hash_sha1.Rd b/man/hash_sha1.Rd new file mode 100644 index 000000000..405aff071 --- /dev/null +++ b/man/hash_sha1.Rd @@ -0,0 +1,62 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/hash.R +\name{hash_sha1} +\alias{hash_sha1} +\alias{hash_raw_sha1} +\alias{hash_obj_sha1} +\alias{hash_file_sha1} +\title{SHA-1 hash} +\usage{ +hash_sha1(x) + +hash_raw_sha1(x) + +hash_obj_sha1(x, serialize_version = 2) + +hash_file_sha1(paths) +} +\arguments{ +\item{x}{Character vector. If not a character vector, then +\code{\link[=as.character]{as.character()}} is used to try to coerce it into one. \code{NA} entries +will have an \code{NA} hash.} + +\item{serialize_version}{Workspace format version to use, see +\code{\link[base:serialize]{base::serialize()}}.} + +\item{paths}{Character vector of file names.} +} +\value{ +\code{hash_sha1()} returns aharacter vector of hexadecimal +SHA-1 hashes. + +\code{hash_raw_sha1()} returns a character scalar. + +\code{hash_obj_sha1()} returns a character scalar. + +\code{hash_file_sha1()} returns a character vector of SHA-1 +hashes. +} +\description{ +Calculate the SHA-1 hash of each element of a character vector. +} +\details{ +\code{hash_raw_sha1()} calculates the SHA-1 hash of the bytes +of a raw vector. + +\code{hash_obj_sha1()} calculates the SHA-1 hash of an R +object. The object is serialized into a binary vector first. + +\code{hash_file_sha1()} calculates the SHA-1 hash of one or +more files. +} +\examples{ +hash_sha1(c("foo", NA, "bar", "")) +} +\seealso{ +Other hash functions: +\code{\link{hash_animal}()}, +\code{\link{hash_emoji}()}, +\code{\link{hash_md5}()}, +\code{\link{hash_sha256}()} +} +\concept{hash functions} diff --git a/man/hash_sha256.Rd b/man/hash_sha256.Rd index 98e232d2e..d90d569a2 100644 --- a/man/hash_sha256.Rd +++ b/man/hash_sha256.Rd @@ -56,6 +56,7 @@ hash_sha256(c("foo", NA, "bar", "")) Other hash functions: \code{\link{hash_animal}()}, \code{\link{hash_emoji}()}, -\code{\link{hash_md5}()} +\code{\link{hash_md5}()}, +\code{\link{hash_sha1}()} } \concept{hash functions} diff --git a/src/cli.h b/src/cli.h index 50212fb96..faf7907dd 100644 --- a/src/cli.h +++ b/src/cli.h @@ -17,6 +17,9 @@ SEXP clic_md5_file(SEXP paths); SEXP clic_sha256(SEXP strs); SEXP clic_sha256_raw(SEXP r); SEXP clic_sha256_file(SEXP paths); +SEXP clic_sha1(SEXP strs); +SEXP clic_sha1_raw(SEXP r); +SEXP clic_sha1_file(SEXP paths); SEXP clic_tty_size(void); SEXP clic_ansi_simplify(SEXP x, SEXP keep_csi); SEXP clic_ansi_substr(SEXP x, SEXP start, SEXP stop); diff --git a/src/init.c b/src/init.c index 2ca1f6d6b..d22f40123 100644 --- a/src/init.c +++ b/src/init.c @@ -46,6 +46,9 @@ static const R_CallMethodDef callMethods[] = { { "clic_sha256", (DL_FUNC) clic_sha256, 1 }, { "clic_sha256_raw", (DL_FUNC) clic_sha256_raw, 1 }, { "clic_sha256_file", (DL_FUNC) clic_sha256_file, 1 }, + { "clic_sha1", (DL_FUNC) clic_sha1, 1 }, + { "clic_sha1_raw", (DL_FUNC) clic_sha1_raw, 1 }, + { "clic_sha1_file", (DL_FUNC) clic_sha1_file, 1 }, { "clic_tty_size", (DL_FUNC) clic_tty_size, 0 }, { "clic_ansi_simplify", (DL_FUNC) clic_ansi_simplify, 2 }, { "clic_ansi_substr", (DL_FUNC) clic_ansi_substr, 3 }, diff --git a/src/sha1.c b/src/sha1.c new file mode 100644 index 000000000..fd24655a9 --- /dev/null +++ b/src/sha1.c @@ -0,0 +1,302 @@ +/********************************************************************* +* Filename: sha1.h +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Defines the API for the corresponding SHA1 implementation. +*********************************************************************/ + +#ifndef SHA1_H +#define SHA1_H + +/*************************** HEADER FILES ***************************/ +#include + +/****************************** MACROS ******************************/ +#define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest + +/**************************** DATA TYPES ****************************/ +typedef unsigned char BYTE; // 8-bit byte +typedef unsigned int WORD32; // 32-bit word, change to "long" for 16-bit machines + +typedef struct { + BYTE data[64]; + WORD32 datalen; + unsigned long long bitlen; + WORD32 state[5]; + WORD32 k[4]; +} SHA1_CTX; + +/*********************** FUNCTION DECLARATIONS **********************/ +void sha1_init(SHA1_CTX *ctx); +void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len); +void sha1_final(SHA1_CTX *ctx, BYTE hash[]); + +#endif // SHA1_H + +/********************************************************************* +* Filename: sha1.c +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Implementation of the SHA1 hashing algorithm. + Algorithm specification can be found here: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + This implementation uses little endian byte order. +*********************************************************************/ + +/*************************** HEADER FILES ***************************/ +#include +#include + +/****************************** MACROS ******************************/ +#define ROTLEFT(a, b) ((a << b) | (a >> (32 - b))) + +/*********************** FUNCTION DEFINITIONS ***********************/ +void sha1_transform(SHA1_CTX *ctx, const BYTE data[]) +{ + WORD32 a, b, c, d, e, i, j, t, m[80]; + + for (i = 0, j = 0; i < 16; ++i, j += 4) + m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]); + for ( ; i < 80; ++i) { + m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]); + m[i] = (m[i] << 1) | (m[i] >> 31); + } + + a = ctx->state[0]; + b = ctx->state[1]; + c = ctx->state[2]; + d = ctx->state[3]; + e = ctx->state[4]; + + for (i = 0; i < 20; ++i) { + t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for ( ; i < 40; ++i) { + t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for ( ; i < 60; ++i) { + t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d)) + e + ctx->k[2] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for ( ; i < 80; ++i) { + t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + + ctx->state[0] += a; + ctx->state[1] += b; + ctx->state[2] += c; + ctx->state[3] += d; + ctx->state[4] += e; +} + +void sha1_init(SHA1_CTX *ctx) +{ + ctx->datalen = 0; + ctx->bitlen = 0; + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xc3d2e1f0; + ctx->k[0] = 0x5a827999; + ctx->k[1] = 0x6ed9eba1; + ctx->k[2] = 0x8f1bbcdc; + ctx->k[3] = 0xca62c1d6; +} + +void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len) +{ + size_t i; + + for (i = 0; i < len; ++i) { + ctx->data[ctx->datalen] = data[i]; + ctx->datalen++; + if (ctx->datalen == 64) { + sha1_transform(ctx, ctx->data); + ctx->bitlen += 512; + ctx->datalen = 0; + } + } +} + +void sha1_final(SHA1_CTX *ctx, BYTE hash[]) +{ + WORD32 i; + + i = ctx->datalen; + + // Pad whatever data is left in the buffer. + if (ctx->datalen < 56) { + ctx->data[i++] = 0x80; + while (i < 56) + ctx->data[i++] = 0x00; + } + else { + ctx->data[i++] = 0x80; + while (i < 64) + ctx->data[i++] = 0x00; + sha1_transform(ctx, ctx->data); + memset(ctx->data, 0, 56); + } + + // Append to the padding the total message's length in bits and transform. + ctx->bitlen += ctx->datalen * 8; + ctx->data[63] = ctx->bitlen; + ctx->data[62] = ctx->bitlen >> 8; + ctx->data[61] = ctx->bitlen >> 16; + ctx->data[60] = ctx->bitlen >> 24; + ctx->data[59] = ctx->bitlen >> 32; + ctx->data[58] = ctx->bitlen >> 40; + ctx->data[57] = ctx->bitlen >> 48; + ctx->data[56] = ctx->bitlen >> 56; + sha1_transform(ctx, ctx->data); + + // Since this implementation uses little endian byte ordering and MD uses big endian, + // reverse all the bytes when copying the final state to the output hash. + for (i = 0; i < 4; ++i) { + hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff; + hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff; + hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff; + hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff; + hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff; + } +} + +static void bin2str(char *to, const unsigned char *p, size_t len) { + static const char *hex = "0123456789abcdef"; + for (; len--; p++) { + *to++ = hex[p[0] >> 4]; + *to++ = hex[p[0] & 0x0f]; + } +} + +#include "errors.h" + +#include + +#include + +SEXP clic_sha1(SEXP strs) { + BYTE hash[20]; + char hex[40]; + SHA1_CTX ctx; + R_xlen_t i, len = XLENGTH(strs); + SEXP result = PROTECT(Rf_allocVector(STRSXP, len)); + + for (i = 0; i < len; i++) { + const char *s = CHAR(STRING_ELT(strs, i)); + sha1_init(&ctx); + sha1_update(&ctx, (const BYTE*) s, strlen(s)); + sha1_final(&ctx, hash); + bin2str(hex, hash, sizeof(hash)); + SET_STRING_ELT( + result, + i, + Rf_mkCharLenCE((const char*) hex, sizeof(hex), CE_UTF8) + ); + } + + UNPROTECT(1); + return result; +} + +SEXP clic_sha1_raw(SEXP r) { + Rbyte *ptr = RAW(r); + Rbyte *end = ptr + XLENGTH(r); + size_t step = SIZE_MAX < 0x40000000 ? SIZE_MAX & ~63 : 0x40000000; + + SHA1_CTX ctx; + BYTE hash[20]; + char hex[40]; + + sha1_init(&ctx); + + while (ptr < end) { + Rbyte *nxt = ptr + step; + if (nxt > end) nxt = end; + sha1_update(&ctx, ptr, nxt - ptr); + ptr = nxt; + } + + sha1_final(&ctx, hash); + bin2str(hex, hash, sizeof(hash)); + + return Rf_ScalarString(Rf_mkCharLenCE( + (const char*) hex, + sizeof(hex), + CE_UTF8 + )); +} + +#include "winfiles.h" + +#include +#include + +SEXP clic_sha1_file(SEXP paths) { + BYTE hash[20]; + char hex[40]; + SHA1_CTX ctx; + R_xlen_t i, len = XLENGTH(paths); +#define BUFSIZE (1 * 1024*1024) + char *buffer = R_alloc(1, BUFSIZE); + SEXP result = PROTECT(Rf_allocVector(STRSXP, len)); + + for (i = 0; i < len; i++) { + const char *cpath = CHAR(STRING_ELT(paths, i)); + int fd = open_file(cpath, O_RDONLY); + if (fd == -1) { + R_THROW_SYSTEM_ERROR("Cannot open file `%s`", cpath); + } + sha1_init(&ctx); + + ssize_t got = read(fd, buffer, BUFSIZE); + if (got == -1) { + close(fd); + R_THROW_SYSTEM_ERROR("Cannot read from file `%s`", cpath); + } + + while (got > 0) { + sha1_update(&ctx, (const BYTE*) buffer, got); + got = read(fd, buffer, BUFSIZE); + if (got == -1) { + close(fd); + R_THROW_SYSTEM_ERROR("Cannot read from file `%s`", cpath); + } + } + + close(fd); + + sha1_final(&ctx, hash); + bin2str(hex, hash, sizeof(hash)); + SET_STRING_ELT( + result, + i, + Rf_mkCharLenCE((const char*) hex, sizeof(hex), CE_UTF8) + ); + } + + UNPROTECT(1); + return result; +} From bc503509cddb65d0007aeb301936e27de76bc7d7 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Wed, 21 Dec 2022 14:26:54 +0100 Subject: [PATCH 21/67] Set empty param-lists to `void` in exported `progress.h` file (#553) --- inst/include/cli/progress.h | 8 ++++---- src/Makevars | 2 +- src/inst.c | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 src/inst.c diff --git a/inst/include/cli/progress.h b/inst/include/cli/progress.h index 03fc04320..8f983bd2a 100644 --- a/inst/include/cli/progress.h +++ b/inst/include/cli/progress.h @@ -105,7 +105,7 @@ static R_INLINE void cli_progress_done(SEXP bar); //' //' Initialize the cli timer without creating a progress bar. -static R_INLINE void cli_progress_init_timer(); +static R_INLINE void cli_progress_init_timer(void); //' ### `cli_progress_num()` //' @@ -115,7 +115,7 @@ static R_INLINE void cli_progress_init_timer(); //' //' Returns the number of currently active progress bars. -static R_INLINE int cli_progress_num(); +static R_INLINE int cli_progress_num(void); //' ### `cli_progress_set()` //' @@ -380,9 +380,9 @@ static R_INLINE void cli_progress_add(SEXP bar, double inc) { } static R_INLINE int cli_progress_num() { - static int (*ptr)() = NULL; + static int (*ptr)(void) = NULL; if (ptr == NULL) { - ptr = (int (*)()) R_GetCCallable("cli", "cli_progress_num"); + ptr = (int (*)(void)) R_GetCCallable("cli", "cli_progress_num"); } return ptr(); } diff --git a/src/Makevars b/src/Makevars index bf5eb423f..624460b41 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1 +1 @@ -PKG_CFLAGS = $(C_VISIBILITY) +PKG_CFLAGS = $(C_VISIBILITY) -I../inst/include diff --git a/src/inst.c b/src/inst.c new file mode 100644 index 000000000..24a7e7cc9 --- /dev/null +++ b/src/inst.c @@ -0,0 +1,9 @@ +#include +#include + +// This file only tests that `inst/cli/progress.h` can be compiled +// without issues + +void test(void) { + cli_progress_bar(0, R_NilValue); +} From 8638a58c6af0406aa56326015ede228345127e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 7 Jan 2023 17:01:45 +0100 Subject: [PATCH 22/67] The progressr progress handler now reports progress correctly Closes #558. --- NEWS.md | 3 +++ R/progress-server.R | 13 ++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index a9aaebb76..2e9102076 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # cli (development version) +* The progressr progress handler now reports progress correctly + (@HenrikBengtsson, #558). + * New `hash_*sha1()` functions to calculate the SHA-1 hash of strings, objects, files. diff --git a/R/progress-server.R b/R/progress-server.R index e1a6c61d7..11043c4c3 100644 --- a/R/progress-server.R +++ b/R/progress-server.R @@ -150,7 +150,6 @@ builtin_handler_cli <- list( builtin_handler_progressr <- list( add = function(bar, .envir) { steps <- if (is.na(bar$total)) 0 else bar$total - bar$progressr_last <- 0L bar$progressr_progressor <- asNamespace("progressr")$progressor( steps, auto_finish = FALSE, @@ -161,18 +160,14 @@ builtin_handler_progressr <- list( }, set = function(bar, .envir) { - amount <- bar$current - bar$progressr_last - bar$last <- bar$current - if (!is.null(bar$progressr_progressor) && amount > 0) { - bar$progressr_progressor(amount = amount) + if (!is.null(bar$progressr_progressor)) { + bar$progressr_progressor(step = bar$current) } }, complete = function(bar, .envir, result) { - amount <- bar$current - bar$progressr_last - bar$last <- bar$current - if (!is.null(bar$progressr_progressor) && amount > 0) { - bar$progressr_progressor(amount = amount, type = "finish") + if (!is.null(bar$progressr_progressor)) { + bar$progressr_progressor(step = bar$current, type = "finish") } }, From c317cee07823240f88d2ad1113be2c5b1fc60707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 7 Jan 2023 18:38:36 +0100 Subject: [PATCH 23/67] Refine progress bar condition Show after `getOption("cli.progress_show_after", 2)/2` if we are less than half way. Closes #542. --- NEWS.md | 5 ++++ R/progress-client.R | 12 ++++++--- man/ansi_collapse.Rd | 14 +++++----- man/cli-config.Rd | 2 ++ man/cli_progress_bar.Rd | 8 +++--- src/progress.c | 50 ++++++++++++++++++++++++++++++----- vignettes/cli-config-user.Rmd | 2 ++ 7 files changed, 72 insertions(+), 21 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2e9102076..8bd7e005d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,11 @@ * New `hash_*sha1()` functions to calculate the SHA-1 hash of strings, objects, files. +* cli now shows progress bars after one second by default, if they + are less than half way at the point. (Or after two seconds, + unconditionally, as before.) See the the `cli.progress_show_after` + option in `?cli-config` for details (#542). + # cli 3.5.0 * New `keypress()` function to read a single key press from a terminal. diff --git a/R/progress-client.R b/R/progress-client.R index 3a3cfaa53..3494590fb 100644 --- a/R/progress-client.R +++ b/R/progress-client.R @@ -109,13 +109,15 @@ #' #' Updating a progress bar on the screen is costly, so cli tries to avoid #' it for quick loops. By default a progress bar is only shown after two -#' seconds. You can change this default with the `cli.progress_show_after` -#' global option (see [cli-config]). +#' seconds, or after half of that if less than 50% of the iterations are +#' complete. You can change the two second default with the +#' `cli.progress_show_after` global option (see [cli-config]). #' #' (In the cli documentation we usually set `cli.progress_show_after` to #' `0` (zero seconds), so progress bars are shown immediately.) #' -#' In this example we only show the progress bar after two seconds. +#' In this example we only show the progress bar after one second, because +#' more than 50% of the iterations remain after one second. #' #' ```{asciicast progress-after} #' #| asciicast_at = "all", @@ -328,6 +330,7 @@ cli_progress_bar <- function(name = NULL, bar$type <- match.arg(type) bar$total <- total bar$show_after <- start + getOption("cli.progress_show_after", 2) + bar$show_50 <- start + getOption("cli.progress_show_after", 2) / 2 bar$format_orig <- bar$format <- format bar$format_done_orig <- bar$format_done <- format_done %||% format bar$format_failed_orig <- bar$format_failed <- format_failed %||% format @@ -428,7 +431,8 @@ cli_progress_update <- function(inc = NULL, set = NULL, total = NULL, now <- .Call(clic_get_time) upd <- .Call(clic_update_due) - if (force || (upd && now > pb$show_after)) { + if (force || (upd && now > pb$show_after) || + (!is.na(pb$total) && upd && now > pb$show_50 && pb$current <= pb$total / 2)) { if (upd) cli_tick_reset() pb$tick <- pb$tick + 1L diff --git a/man/ansi_collapse.Rd b/man/ansi_collapse.Rd index 986dec928..b4dd3a457 100644 --- a/man/ansi_collapse.Rd +++ b/man/ansi_collapse.Rd @@ -23,7 +23,7 @@ to collapse.} \item{last}{Last separator, if there is no truncation. E.g. use \code{", and "} for the Oxford comma.} -\item{trunc}{MAximum number of elements to show. For \code{sytle = "head"} +\item{trunc}{Maximum number of elements to show. For \code{style = "head"} at least \code{trunc = 1} is used. For \code{style = "both-ends"} at least \code{trunc = 5} is used, even if a smaller number is specified.} @@ -32,9 +32,9 @@ This is a hard limit, and the output will never exceed it. This argument is not implemented for the \code{"both-ends"} style, which always uses \code{Inf}, with a warning if a fininte \code{width} value is set.} -\item{ellipsis}{character string to use at the place of the truncation. -By default the Unicode ellipsis character is used if the console is -UTF-8 and three dots otherwise.} +\item{ellipsis}{Character string to use at the place of the truncation. +By default, the Unicode ellipsis character is used if the console is +UTF-8, and three dots otherwise.} \item{style}{Truncation style: \itemize{ @@ -50,8 +50,6 @@ vector are \code{NA}. } \description{ Features: -} -\details{ \itemize{ \item custom separator, \item custom last separator: \code{last} argument, @@ -59,7 +57,7 @@ Features: \item uses Unicode ellipsis character on UTF-8 console, \item can collapse "from both ends", with \code{style = "both-ends"}, \item can consider a limit for the display width of the result, in characters, -\item handles ANSI control sequences correctly when measuring dipaly width. +\item handles ANSI control sequences correctly when measuring display width. } } \examples{ @@ -72,5 +70,5 @@ ansi_collapse(letters, trunc = 5) ansi_collapse(letters, trunc = 5, style = "head") } \seealso{ -\code{glue_collapse} in the glue package incpired this function +\code{glue_collapse} in the glue package inspired this function } diff --git a/man/cli-config.Rd b/man/cli-config.Rd index a4afe568e..46d92866e 100644 --- a/man/cli-config.Rd +++ b/man/cli-config.Rd @@ -236,6 +236,8 @@ See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()} Delay before showing a progress bar, in seconds. Progress bars that finish before this delay are not shown at all. +cli also shows progress bars that have more than 50\% to go after half of +this delay has passed. } \subsection{\code{cli.spinner}}{ diff --git a/man/cli_progress_bar.Rd b/man/cli_progress_bar.Rd index 76bfef394..dbe23e30f 100644 --- a/man/cli_progress_bar.Rd +++ b/man/cli_progress_bar.Rd @@ -237,13 +237,15 @@ fun() Updating a progress bar on the screen is costly, so cli tries to avoid it for quick loops. By default a progress bar is only shown after two -seconds. You can change this default with the \code{cli.progress_show_after} -global option (see \link{cli-config}). +seconds, or after half of that if less than 50\% of the iterations are +complete. You can change the two second default with the +\code{cli.progress_show_after} global option (see \link{cli-config}). (In the cli documentation we usually set \code{cli.progress_show_after} to \code{0} (zero seconds), so progress bars are shown immediately.) -In this example we only show the progress bar after two seconds. +In this example we only show the progress bar after one second, because +more than 50\% of the iterations remain after one second. \if{html}{\out{
}}\preformatted{fun <- function() \{ cli_alert("Starting now, at \{Sys.time()\}") diff --git a/src/progress.c b/src/progress.c index 885c8abec..9307e527e 100644 --- a/src/progress.c +++ b/src/progress.c @@ -158,6 +158,7 @@ SEXP cli_progress_bar(vint **ptr, double total, SEXP config) { Rf_defineVar(P(Rf_install("type")), P(Rf_mkString("iterator")), bar); Rf_defineVar(P(Rf_install("total")), P(Rf_ScalarReal(total)), bar); Rf_defineVar(P(Rf_install("show_after")), P(Rf_ScalarReal(now + sa)), bar); + Rf_defineVar(P(Rf_install("show_50")), P(Rf_ScalarReal(now + sa/2)), bar); Rf_defineVar(P(Rf_install("format")), R_NilValue, bar); Rf_defineVar(P(Rf_install("format_done")), R_NilValue, bar); Rf_defineVar(P(Rf_install("format_failed")), R_NilValue, bar); @@ -170,7 +171,7 @@ SEXP cli_progress_bar(vint **ptr, double total, SEXP config) { Rf_defineVar(P(Rf_install("tick")), P(Rf_ScalarReal(0)), bar); Rf_defineVar(P(Rf_install("extra")), R_NilValue, bar); - UNPROTECT(28); + UNPROTECT(30); if (!config || Rf_isNull(config)) { /* NULL pointer or R NULL, use defaults */ @@ -267,7 +268,18 @@ void cli_progress_set(SEXP bar, double set) { if (cli__reset) *cli_timer_flag = 0; double now = clic__get_time(); SEXP show_after = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_after")))); - if (now > REAL(show_after)[0]) cli__progress_update(bar); + if (now > REAL(show_after)[0]) { + cli__progress_update(bar); + } else { + SEXP show_50 = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_50")))); + SEXP total = PROTECT(clic__find_var(bar, PROTECT(Rf_install("total")))); + if (now > REAL(show_50)[0] && + REAL(total)[0] != NA_REAL && + set <= REAL(total)[0] / 2) { + cli__progress_update(bar); + } + UNPROTECT(4); + } UNPROTECT(2); } UNPROTECT(3); @@ -286,7 +298,18 @@ void cli_progress_add(SEXP bar, double inc) { if (cli__reset) *cli_timer_flag = 0; double now = clic__get_time(); SEXP show_after = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_after")))); - if (now > REAL(show_after)[0]) cli__progress_update(bar); + if (now > REAL(show_after)[0]) { + cli__progress_update(bar); + } else { + SEXP show_50 = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_50")))); + SEXP total = PROTECT(clic__find_var(bar, PROTECT(Rf_install("total")))); + if (now > REAL(show_50)[0] && + REAL(total)[0] != NA_REAL && + crnt + inc <= REAL(total)[0] / 2) { + cli__progress_update(bar); + } + UNPROTECT(4); + } UNPROTECT(2); } UNPROTECT(4); @@ -330,6 +353,7 @@ void cli_progress_sleep(int s, long ns) { } void cli_progress_update(SEXP bar, double set, double inc, int force) { + double crnt = 0; PROTECT(bar); if (isNull(bar)) { UNPROTECT(1); @@ -337,12 +361,14 @@ void cli_progress_update(SEXP bar, double set, double inc, int force) { } SEXP current = PROTECT(Rf_install("current")); if (set >= 0) { + crnt = set; Rf_defineVar(current, PROTECT(ScalarReal(set)), bar); UNPROTECT(1); } else { - double crnt = REAL(PROTECT(clic__find_var(bar, current)))[0]; + crnt = REAL(PROTECT(clic__find_var(bar, current)))[0]; if (inc != 0) { - Rf_defineVar(current, PROTECT(ScalarReal(crnt + inc)), bar); + crnt = crnt + inc; + Rf_defineVar(current, PROTECT(ScalarReal(crnt)), bar); UNPROTECT(1); } UNPROTECT(1); @@ -353,7 +379,19 @@ void cli_progress_update(SEXP bar, double set, double inc, int force) { if (cli__reset) *cli_timer_flag = 0; double now = clic__get_time(); SEXP show_after = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_after")))); - if (now > REAL(show_after)[0]) cli__progress_update(bar); + if (now > REAL(show_after)[0]) { + cli__progress_update(bar); + } else { + SEXP show_50 = PROTECT(clic__find_var(bar, PROTECT(Rf_install("show_50")))); + SEXP total = PROTECT(clic__find_var(bar, PROTECT(Rf_install("total")))); + if (now > REAL(show_50)[0] && + REAL(total)[0] != NA_REAL && + crnt <= REAL(total)[0] / 2) { + cli__progress_update(bar); + } + UNPROTECT(4); + + } UNPROTECT(2); } diff --git a/vignettes/cli-config-user.Rmd b/vignettes/cli-config-user.Rmd index c7c5d9aee..1a1e34d0a 100644 --- a/vignettes/cli-config-user.Rmd +++ b/vignettes/cli-config-user.Rmd @@ -204,6 +204,8 @@ See [cli_progress_builtin_handlers()]. Delay before showing a progress bar, in seconds. Progress bars that finish before this delay are not shown at all. +cli also shows progress bars that have more than 50% to go after half of +this delay has passed. ### `cli.spinner` From 93792618226c55720e6df11d343666ba3533b29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 6 Jan 2023 17:21:02 +0100 Subject: [PATCH 24/67] format_inline() now keeps newline charaters --- R/cli.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/cli.R b/R/cli.R index 515a46f5d..ac266b83b 100644 --- a/R/cli.R +++ b/R/cli.R @@ -109,10 +109,12 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) { #' format_inline("A message for {.emph later}, thanks {.fn format_inline}.") format_inline <- function(..., .envir = parent.frame(), collapse = TRUE) { + str <- paste0(unlist(list(...), use.names = FALSE), collapse = "") + str <- gsub("\n", "\f", str, fixed = TRUE) opts <- options(cli.width = Inf) on.exit(options(opts), add = TRUE) cli_fmt( - cli_text(..., .envir = .envir), + cli_text(str, .envir = .envir), collapse = collapse, strip_newline = TRUE ) From 9ad08f4303b5859a4dc1cebaaa3ad0057bcd6a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 7 Jan 2023 15:45:07 +0100 Subject: [PATCH 25/67] New `keep_newlines = TRUE` argument to `format_inline()` It does not break any tests, but we might need to change the default to `FALSE` if it breaks reverse dependencies. --- NEWS.md | 3 +++ R/cli.R | 9 +++++++-- man/format_inline.Rd | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8bd7e005d..7288a8601 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,9 @@ unconditionally, as before.) See the the `cli.progress_show_after` option in `?cli-config` for details (#542). +* `format_inline()` now has a new argument `keep_newlines`, and it keeps + newline characters by default. + # cli 3.5.0 * New `keypress()` function to read a single key press from a terminal. diff --git a/R/cli.R b/R/cli.R index ac266b83b..f9760d57e 100644 --- a/R/cli.R +++ b/R/cli.R @@ -102,15 +102,20 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) { #' @param .envir Environment to evaluate the expressions in. #' @param collapse Whether to collapse the result if it has multiple #' lines, e.g. because of `\f` characters. +#' @param keep_newlines Whether to keep newlines in the result, or treat +#' them as regular space characters. #' @return Character scalar, the formatted string. #' #' @export #' @examples #' format_inline("A message for {.emph later}, thanks {.fn format_inline}.") -format_inline <- function(..., .envir = parent.frame(), collapse = TRUE) { +format_inline <- function(..., .envir = parent.frame(), collapse = TRUE, + keep_newlines = TRUE) { str <- paste0(unlist(list(...), use.names = FALSE), collapse = "") - str <- gsub("\n", "\f", str, fixed = TRUE) + if (keep_newlines) { + str <- gsub("\n", "\f", str, fixed = TRUE) + } opts <- options(cli.width = Inf) on.exit(options(opts), add = TRUE) cli_fmt( diff --git a/man/format_inline.Rd b/man/format_inline.Rd index 0220479dd..f48bbc876 100644 --- a/man/format_inline.Rd +++ b/man/format_inline.Rd @@ -4,7 +4,12 @@ \alias{format_inline} \title{Format and returns a line of text} \usage{ -format_inline(..., .envir = parent.frame(), collapse = TRUE) +format_inline( + ..., + .envir = parent.frame(), + collapse = TRUE, + keep_newlines = TRUE +) } \arguments{ \item{...}{Passed to \code{\link[=cli_text]{cli_text()}}.} @@ -13,6 +18,9 @@ format_inline(..., .envir = parent.frame(), collapse = TRUE) \item{collapse}{Whether to collapse the result if it has multiple lines, e.g. because of \verb{\\f} characters.} + +\item{keep_newlines}{Whether to keep newlines in the result, or treat +them as regular space characters.} } \value{ Character scalar, the formatted string. From 542dc860834d63be08a4e1d0ed01bcb47977837f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 7 Jan 2023 15:52:52 +0100 Subject: [PATCH 26/67] Add test cases for `format_inline(..., keep_newlines)` --- tests/testthat/_snaps/inline-2.md | 38 +++++++++++++++++++++++++++++++ tests/testthat/test-inline-2.R | 15 ++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/testthat/_snaps/inline-2.md b/tests/testthat/_snaps/inline-2.md index 3c03bc946..e9fb53ceb 100644 --- a/tests/testthat/_snaps/inline-2.md +++ b/tests/testthat/_snaps/inline-2.md @@ -398,3 +398,41 @@ Caused by error: ! non-numeric argument to binary operator +# format_inline and newlines + + Code + format_inline("foo\nbar", keep_newlines = TRUE) + Output + [1] "foo\nbar" + Code + format_inline("\nfoo\n\nbar\n", keep_newlines = TRUE) + Output + [1] "\nfoo\n\nbar\n" + Code + format_inline("foo\fbar", keep_newlines = TRUE) + Output + [1] "foo\nbar" + Code + format_inline("\ffoo\f\fbar\f", keep_newlines = TRUE) + Output + [1] "\nfoo\n\nbar\n" + +--- + + Code + format_inline("foo\nbar", keep_newlines = FALSE) + Output + [1] "foo bar" + Code + format_inline("\nfoo\n\nbar\n", keep_newlines = FALSE) + Output + [1] "foo\n\nbar" + Code + format_inline("foo\fbar", keep_newlines = FALSE) + Output + [1] "foo\nbar" + Code + format_inline("\ffoo\f\fbar\f", keep_newlines = FALSE) + Output + [1] "\nfoo\n\nbar\n" + diff --git a/tests/testthat/test-inline-2.R b/tests/testthat/test-inline-2.R index ddecfdfcf..c4bea05dc 100644 --- a/tests/testthat/test-inline-2.R +++ b/tests/testthat/test-inline-2.R @@ -181,3 +181,18 @@ test_that("various errors", { transform = function(x) sanitize_call(sanitize_srcref(x)) ) }) + +test_that("format_inline and newlines", { + expect_snapshot({ + format_inline("foo\nbar", keep_newlines = TRUE) + format_inline("\nfoo\n\nbar\n", keep_newlines = TRUE) + format_inline("foo\fbar", keep_newlines = TRUE) + format_inline("\ffoo\f\fbar\f", keep_newlines = TRUE) + }) + expect_snapshot({ + format_inline("foo\nbar", keep_newlines = FALSE) + format_inline("\nfoo\n\nbar\n", keep_newlines = FALSE) + format_inline("foo\fbar", keep_newlines = FALSE) + format_inline("\ffoo\f\fbar\f", keep_newlines = FALSE) + }) +}) From 7eb58fe403d863934d364dbd0cc44722938e1956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Mon, 9 Jan 2023 08:32:04 +0100 Subject: [PATCH 27/67] Add more (void) args to pacify CRAN's compilers --- inst/include/cli/progress.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/include/cli/progress.h b/inst/include/cli/progress.h index 8f983bd2a..809fad8a1 100644 --- a/inst/include/cli/progress.h +++ b/inst/include/cli/progress.h @@ -279,7 +279,7 @@ static void cli_progress_done2(SEXP bar) { } #endif -static R_INLINE void cli_progress_init_timer() { +static R_INLINE void cli_progress_init_timer(void) { static void (*ptr)(vint **) = NULL; if (ptr == NULL) { ptr = (void (*)(vint **)) R_GetCCallable("cli", "cli_progress_init_timer"); @@ -379,7 +379,7 @@ static R_INLINE void cli_progress_add(SEXP bar, double inc) { ptr(bar, inc); } -static R_INLINE int cli_progress_num() { +static R_INLINE int cli_progress_num(void) { static int (*ptr)(void) = NULL; if (ptr == NULL) { ptr = (int (*)(void)) R_GetCCallable("cli", "cli_progress_num"); From a7c63c249348dae10b2484ad06f5e1ca9f9a2d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Mon, 9 Jan 2023 11:54:52 +0100 Subject: [PATCH 28/67] `format_inline()` now keeps all whitespace as is by default And has a new argument: `keep_whitespace` to choose the old behavior. --- NEWS.md | 4 ++-- R/cli.R | 22 ++++++++++++++-------- R/cliapp.R | 12 ++++++++++-- R/glue.R | 6 ++++-- R/inline.R | 8 +++++--- R/internals.R | 16 ++++++++++------ man/format_inline.Rd | 6 +++--- tests/testthat/_snaps/inline-2.md | 20 ++++++++++---------- tests/testthat/test-inline-2.R | 17 +++++++++-------- 9 files changed, 67 insertions(+), 44 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7288a8601..75e4e37c1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,8 +11,8 @@ unconditionally, as before.) See the the `cli.progress_show_after` option in `?cli-config` for details (#542). -* `format_inline()` now has a new argument `keep_newlines`, and it keeps - newline characters by default. +* `format_inline()` now has a new argument `keep_whitespace`, and it keeps + whitespace, including newline and form feed characters by default. # cli 3.5.0 diff --git a/R/cli.R b/R/cli.R index f9760d57e..24c26743a 100644 --- a/R/cli.R +++ b/R/cli.R @@ -102,8 +102,8 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) { #' @param .envir Environment to evaluate the expressions in. #' @param collapse Whether to collapse the result if it has multiple #' lines, e.g. because of `\f` characters. -#' @param keep_newlines Whether to keep newlines in the result, or treat -#' them as regular space characters. +#' @param keep_whitespace Whether to keep all whitepace (spaces, newlines +#' and form feeds) as is in the input. #' @return Character scalar, the formatted string. #' #' @export @@ -111,15 +111,12 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) { #' format_inline("A message for {.emph later}, thanks {.fn format_inline}.") format_inline <- function(..., .envir = parent.frame(), collapse = TRUE, - keep_newlines = TRUE) { - str <- paste0(unlist(list(...), use.names = FALSE), collapse = "") - if (keep_newlines) { - str <- gsub("\n", "\f", str, fixed = TRUE) - } + keep_whitespace = TRUE) { opts <- options(cli.width = Inf) on.exit(options(opts), add = TRUE) + fun <- if (keep_whitespace) cli_inline else cli_text cli_fmt( - cli_text(str, .envir = .envir), + fun(..., .envir = .envir), collapse = collapse, strip_newline = TRUE ) @@ -208,6 +205,15 @@ cli_text <- function(..., .envir = parent.frame()) { cli__message("text", list(text = glue_cmd(..., .envir = .envir, .call = sys.call()))) } +cli_inline <- function(..., .envir = parent.frame()) { + cli__message( + "inline_text", + list( + text = glue_cmd(..., .envir = .envir, .call = sys.call(), .trim = FALSE) + ) + ) +} + #' CLI verbatim text #' #' It is not wrapped, but printed as is. Long lines will overflow. diff --git a/R/cliapp.R b/R/cliapp.R index d7b0c2eff..9d985afa1 100644 --- a/R/cliapp.R +++ b/R/cliapp.R @@ -40,6 +40,10 @@ cliapp <- function(theme = getOption("cli.theme"), clii_text(app, text), ## Text, not wrapped + inline_text = function(text) + clii_inline_text(app, text), + + ## Text, not wrapped, verbatim verbatim = function(...) clii_verbatim(app, ...), @@ -114,9 +118,9 @@ cliapp <- function(theme = getOption("cli.theme"), get_current_style = function() utils::tail(app$styles, 1)[[1]], - xtext = function(text = NULL, .list = NULL, indent = 0, padding = 0) + xtext = function(text = NULL, .list = NULL, indent = 0, padding = 0, wrap = TRUE) clii__xtext(app, text, .list = .list, indent = indent, - padding = padding), + padding = padding, wrap = wrap), vspace = function(n = 1) clii__vspace(app, n), @@ -163,6 +167,10 @@ clii_text <- function(app, text) { app$xtext(text) } +clii_inline_text <- function(app, text) { + app$xtext(text, wrap = FALSE) +} + clii_verbatim <- function(app, ..., .envir) { style <- app$get_current_style() text <- unlist(strsplit(unlist(list(...)), "\n", fixed = TRUE)) diff --git a/R/glue.R b/R/glue.R index 0d479edac..753c38e75 100644 --- a/R/glue.R +++ b/R/glue.R @@ -11,7 +11,7 @@ glue <- function(text, .envir = parent.frame(), .transformer = identity_transformer, - .open = "{", .close = "}", .cli = FALSE) { + .open = "{", .close = "}", .cli = FALSE, .trim = TRUE) { text <- paste0(text, collapse = "") @@ -23,7 +23,9 @@ glue <- function(text, .envir = parent.frame(), return(text) } - text <- trim(text) + if (.trim) { + text <- trim(text) + } f <- function(expr) { eval_func <- as.character(.transformer(expr, .envir) %||% character()) diff --git a/R/inline.R b/R/inline.R index 69b627c2b..3f1ba56e3 100644 --- a/R/inline.R +++ b/R/inline.R @@ -231,7 +231,8 @@ clii__inline <- function(app, text, .list) { .envir = t$values, .transformer = inline_transformer, .open = paste0("<", t$values$marker), - .close = paste0(t$values$marker, ">") + .close = paste0(t$values$marker, ">"), + .trim = FALSE ) }) paste(out, collapse = "") @@ -323,7 +324,7 @@ make_cmd_transformer <- function(values, .call = NULL) { } } -glue_cmd <- function(..., .envir, .call = sys.call(-1)) { +glue_cmd <- function(..., .envir, .call = sys.call(-1), .trim = TRUE) { str <- paste0(unlist(list(...), use.names = FALSE), collapse = "") values <- new.env(parent = emptyenv()) transformer <- make_cmd_transformer(values, .call = .call) @@ -331,7 +332,8 @@ glue_cmd <- function(..., .envir, .call = sys.call(-1)) { str, .envir = .envir, .transformer = transformer, - .cli = TRUE + .cli = TRUE, + .trim = .trim ) glue_delay( str = post_process_plurals(pstr, values), diff --git a/R/internals.R b/R/internals.R index 76239dd50..754346570 100644 --- a/R/internals.R +++ b/R/internals.R @@ -3,7 +3,7 @@ call_if_fun <- function(x) { if (is.function(x)) x() else x } -clii__xtext <- function(app, text, .list, indent, padding, ln = TRUE) { +clii__xtext <- function(app, text, .list, indent, padding, ln = TRUE, wrap = TRUE) { style <- app$get_current_style() text <- app$inline(text, .list = .list) exdent <- style$`text-exdent` %||% 0L @@ -17,11 +17,15 @@ clii__xtext <- function(app, text, .list, indent, padding, ln = TRUE) { if (!is.null(style$fmt)) text <- style$fmt(text) - text <- ansi_strwrap( - text, - exdent = exdent, - width = app$get_width(extra = padding) - ) + if (wrap) { + text <- ansi_strwrap( + text, + exdent = exdent, + width = app$get_width(extra = padding) + ) + } else { + text <- ansi_simplify(text) + } app$cat_ln(text, indent = indent, padding) invisible(app) diff --git a/man/format_inline.Rd b/man/format_inline.Rd index f48bbc876..d2ad106b2 100644 --- a/man/format_inline.Rd +++ b/man/format_inline.Rd @@ -8,7 +8,7 @@ format_inline( ..., .envir = parent.frame(), collapse = TRUE, - keep_newlines = TRUE + keep_whitespace = TRUE ) } \arguments{ @@ -19,8 +19,8 @@ format_inline( \item{collapse}{Whether to collapse the result if it has multiple lines, e.g. because of \verb{\\f} characters.} -\item{keep_newlines}{Whether to keep newlines in the result, or treat -them as regular space characters.} +\item{keep_whitespace}{Whether to keep all whitepace (spaces, newlines +and form feeds) as is in the input.} } \value{ Character scalar, the formatted string. diff --git a/tests/testthat/_snaps/inline-2.md b/tests/testthat/_snaps/inline-2.md index e9fb53ceb..c900a788a 100644 --- a/tests/testthat/_snaps/inline-2.md +++ b/tests/testthat/_snaps/inline-2.md @@ -401,38 +401,38 @@ # format_inline and newlines Code - format_inline("foo\nbar", keep_newlines = TRUE) + format_inline("foo\nbar") Output [1] "foo\nbar" Code - format_inline("\nfoo\n\nbar\n", keep_newlines = TRUE) + format_inline("\nfoo\n\nbar\n") Output [1] "\nfoo\n\nbar\n" Code - format_inline("foo\fbar", keep_newlines = TRUE) + format_inline("foo\fbar") Output - [1] "foo\nbar" + [1] "foo\fbar" Code - format_inline("\ffoo\f\fbar\f", keep_newlines = TRUE) + format_inline("\ffoo\f\fbar\f") Output - [1] "\nfoo\n\nbar\n" + [1] "\ffoo\f\fbar\f" --- Code - format_inline("foo\nbar", keep_newlines = FALSE) + format_inline("foo\nbar", keep_whitespace = FALSE) Output [1] "foo bar" Code - format_inline("\nfoo\n\nbar\n", keep_newlines = FALSE) + format_inline("\nfoo\n\nbar\n", keep_whitespace = FALSE) Output [1] "foo\n\nbar" Code - format_inline("foo\fbar", keep_newlines = FALSE) + format_inline("foo\fbar", keep_whitespace = FALSE) Output [1] "foo\nbar" Code - format_inline("\ffoo\f\fbar\f", keep_newlines = FALSE) + format_inline("\ffoo\f\fbar\f", keep_whitespace = FALSE) Output [1] "\nfoo\n\nbar\n" diff --git a/tests/testthat/test-inline-2.R b/tests/testthat/test-inline-2.R index c4bea05dc..97bbe6b50 100644 --- a/tests/testthat/test-inline-2.R +++ b/tests/testthat/test-inline-2.R @@ -184,15 +184,16 @@ test_that("various errors", { test_that("format_inline and newlines", { expect_snapshot({ - format_inline("foo\nbar", keep_newlines = TRUE) - format_inline("\nfoo\n\nbar\n", keep_newlines = TRUE) - format_inline("foo\fbar", keep_newlines = TRUE) - format_inline("\ffoo\f\fbar\f", keep_newlines = TRUE) + format_inline("foo\nbar") + format_inline("\nfoo\n\nbar\n") + format_inline("foo\fbar") + format_inline("\ffoo\f\fbar\f") }) + expect_snapshot({ - format_inline("foo\nbar", keep_newlines = FALSE) - format_inline("\nfoo\n\nbar\n", keep_newlines = FALSE) - format_inline("foo\fbar", keep_newlines = FALSE) - format_inline("\ffoo\f\fbar\f", keep_newlines = FALSE) + format_inline("foo\nbar", keep_whitespace = FALSE) + format_inline("\nfoo\n\nbar\n", keep_whitespace = FALSE) + format_inline("foo\fbar", keep_whitespace = FALSE) + format_inline("\ffoo\f\fbar\f", keep_whitespace = FALSE) }) }) From 4cc6312883f2842e948f34a816ce8e846f323a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Mon, 9 Jan 2023 14:05:35 +0100 Subject: [PATCH 29/67] Increment version number to 3.6.0 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 04846192a..b01688bab 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.5.0.9000 +Version: 3.6.0 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 75e4e37c1..714539878 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cli (development version) +# cli 3.6.0 * The progressr progress handler now reports progress correctly (@HenrikBengtsson, #558). From 4303664afdd38714dd7b56ec848b888dc9af8cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Mon, 9 Jan 2023 18:37:57 +0100 Subject: [PATCH 30/67] Increment version number to 3.6.0.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b01688bab..993d6ea3d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.6.0 +Version: 3.6.0.9000 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 714539878..c8a1f19c7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# cli (development version) + # cli 3.6.0 * The progressr progress handler now reports progress correctly From 01f932adafd58a59d596b745bf88359c5cb5a969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 10 Jan 2023 15:48:43 +0100 Subject: [PATCH 31/67] Fix ASAN warnings Closes #565. --- src/sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sha1.c b/src/sha1.c index fd24655a9..2b9224828 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -58,7 +58,7 @@ void sha1_transform(SHA1_CTX *ctx, const BYTE data[]) WORD32 a, b, c, d, e, i, j, t, m[80]; for (i = 0, j = 0; i < 16; ++i, j += 4) - m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]); + m[i] = ((WORD32)data[j] << 24) + ((WORD32)data[j + 1] << 16) + ((WORD32)data[j + 2] << 8) + ((WORD32)data[j + 3]); for ( ; i < 80; ++i) { m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]); m[i] = (m[i] << 1) | (m[i] >> 31); From cd71ab4d1be9fe4d6dcf3d7a729b54e6f3b78c0e Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 9 Feb 2023 22:23:07 +0100 Subject: [PATCH 32/67] Fix/tweak documentation --- R/cliapp-docs.R | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index cb863ffb1..0d4f50dc8 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -46,26 +46,26 @@ #' * `email` for an email address. #' If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), #' then cli creates a clickable link. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `emph` for emphasized text. #' * `envvar` for the name of an environment variable. #' * `field` for a generic field, e.g. in a named list. #' * `file` for a file name. If the terminal supports ANSI hyperlinks (e.g. #' RStudio, iTerm2, etc.), then cli creates a clickable link that opens #' the file in RStudio or with the default app for the file type. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `fun` for a function name. If it is in the `package::function_name` #' form, and the terminal supports ANSI hyperlinks (e.g. RStudio, #' iTerm2, etc.), then cli creates a clickable link. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `help` is a help page of a _function_. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `href` creates a hyperlink, potentially with a link text. #' If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), #' then cli creates a clickable link. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `key` for a keyboard key. #' * `obj_type_friendly` formats the type of an R object in a readable way, #' and it should be used with `{}`, see an example below. @@ -75,23 +75,24 @@ #' * `pkg` for a package name. #' * `run` is an R expression, that is potentially clickable if the terminal #' supports ANSI hyperlinks to runnable code (e.g. RStudio). -#' It supports link text. See [links] for more about cli hyperlinks. +#' It supports link text. See [links] for more information about cli +#' hyperlinks. #' * `strong` for strong importance. -#' * `topic` is a help page of a _ropic_. +#' * `topic` is a help page of a _topic_. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `type` formats the type of an R object in a readable way, and it #' should be used with `{}`, see an example below. #' * `url` for a URL. If the terminal supports ANSI hyperlinks (e.g. #' RStudio, iTerm2, etc.), then cli creates a clickable link. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' * `var` for a variable name. #' * `val` for a generic "value". #' * `vignette` is a vignette. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. -#' See [links] for more about cli hyperlinks. +#' See [links] for more information about cli hyperlinks. #' #' ```{asciicast inline-examples} #' ul <- cli_ul() From d5632e6c07d72bc4679c10862d96648be2edd9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 22 Feb 2023 10:34:46 +0100 Subject: [PATCH 33/67] Update errors.R from processx --- R/errors.R | 83 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/R/errors.R b/R/errors.R index be487ff1b..c387db412 100644 --- a/R/errors.R +++ b/R/errors.R @@ -139,6 +139,26 @@ # * Use a `procsrcref` column for processed source references. # Otherwise testthat (and probably other rlang based packages), will # pick up the `srcref` column, and they expect an `srcref` object there. +# +# ### 3.1.0 -- 2022-10-04 +# +# * Add ANSI hyperlinks to stack traces, if we have a recent enough +# cli package that supports this. +# +# ### 3.1.1 -- 2022-11-17 +# +# * Use `[[` instead of `$` to fix some partial matches. +# * Use fully qualified `base::stop()` to enable overriding `stop()` +# in a package. (Makes sense if compat files use `stop()`. +# * The `is_interactive()` function is now exported. +# +# ### 3.1.2 -- 2022-11-18 +# +# * The `parent` condition can now be an interrupt. +# +# ### 3.1.3 -- 2023-01-15 +# +# * Now we do not load packages when walking the trace. err <- local({ @@ -212,10 +232,10 @@ err <- local({ throw(new_error("Parent condition must be a condition object")) } - if (isTRUE(cond$call)) { - cond$call <- sys.call(-1) %||% sys.call() - } else if (identical(cond$call, FALSE)) { - cond$call <- NULL + if (isTRUE(cond[["call"]])) { + cond[["call"]] <- sys.call(-1) %||% sys.call() + } else if (identical(cond[["call"]], FALSE)) { + cond[["call"]] <- NULL } cond <- process_call(cond) @@ -294,7 +314,7 @@ err <- local({ opts <- options(show.error.messages = FALSE) on.exit(options(opts), add = TRUE) - stop(cond) + base::stop(cond) } # -- rethrow with parent ----------------------------------------------- @@ -350,7 +370,7 @@ err <- local({ .hide_from_trace <- 0:1 e$srcref <- srcref e$procsrcref <- NULL - e$call <- call + e[["call"]] <- call name <- native_name(.NAME) err <- new_error("Native call to `", name, "` failed", call. = call1) cerror <- if (inherits(e, "simpleError")) "c_error" @@ -385,7 +405,7 @@ err <- local({ .hide_from_trace <- 0:1 e$srcref <- srcref e$procsrcref <- NULL - e$call <- call + e[["call"]] <- call name <- native_name(.NAME) err <- new_error("Native call to `", name, "` failed", call. = call1) cerror <- if (inherits(e, "simpleError")) "c_error" @@ -531,6 +551,7 @@ err <- local({ if (ns == "base") return("::") if (! ns %in% loadedNamespaces()) return("") name <- call_name(call) + if (! ns %in% loadedNamespaces()) return("::") nsenv <- asNamespace(ns)$.__NAMESPACE__. if (is.null(nsenv)) return("::") if (is.null(nsenv$exports)) return(":::") @@ -558,7 +579,7 @@ err <- local({ procsrcref = procsrcrefs, pid = pids ) - trace$call <- calls + trace[["call"]] <- calls class(trace) <- c("rlib_trace_3_0", "rlib_trace", "tbl", "data.frame") trace @@ -691,12 +712,20 @@ err <- local({ # -- condition message with cli --------------------------------------- + cnd_message_robust <- function(cond) { + class(cond) <- setdiff(class(cond), "rlib_error_3_0") + conditionMessage(cond) %||% + (if (inherits(cond, "interrupt")) "interrupt") %||% + "" + } + cnd_message_cli <- function(cond, full = FALSE) { exp <- paste0(cli::col_yellow("!"), " ") add_exp <- is.null(names(cond$message)) + msg <- cnd_message_robust(cond) c( - paste0(if (add_exp) exp, cond$message), + paste0(if (add_exp) exp, msg), if (inherits(cond$parent, "condition")) { msg <- if (full && inherits(cond$parent, "rlib_error_3_0")) { format(cond$parent, @@ -706,6 +735,8 @@ err <- local({ header = FALSE, advice = FALSE ) + } else if (inherits(cond$parent, "interrupt")) { + "interrupt" } else { conditionMessage(cond$parent) } @@ -724,7 +755,7 @@ err <- local({ exp <- "! " add_exp <- is.null(names(cond$message)) c( - paste0(if (add_exp) exp, cond$message), + paste0(if (add_exp) exp, cnd_message_robust(cond)), if (inherits(cond$parent, "condition")) { msg <- if (full && inherits(cond$parent, "rlib_error_3_0")) { format(cond$parent, @@ -734,6 +765,8 @@ err <- local({ header = FALSE, advice = FALSE ) + } else if (inherits(cond$parent, "interrupt")) { + "interrupt" } else { conditionMessage(cond$parent) } @@ -777,7 +810,7 @@ err <- local({ format_header_line_cli <- function(x, prefix = NULL) { p_error <- format_error_heading_cli(x, prefix) - p_call <- format_call_cli(x$call) + p_call <- format_call_cli(x[["call"]]) p_srcref <- format_srcref_cli(conditionCall(x), x$procsrcref %||% x$srcref) paste0(p_error, p_call, p_srcref, if (!is.null(conditionCall(x))) ":") } @@ -859,11 +892,11 @@ err <- local({ srcref <- if ("srcref" %in% names(x) || "procsrcref" %in% names(x)) { vapply( seq_len(nrow(x)), - function(i) format_srcref_cli(x$call[[i]], x$procsrcref[[i]] %||% x$srcref[[i]]), + function(i) format_srcref_cli(x[["call"]][[i]], x$procsrcref[[i]] %||% x$srcref[[i]]), character(1) ) } else { - unname(vapply(x$call, format_srcref_cli, character(1))) + unname(vapply(x[["call"]], format_srcref_cli, character(1))) } lines <- paste0( @@ -885,7 +918,10 @@ err <- local({ } format_trace_call_cli <- function(call, ns = "") { - envir <- tryCatch(asNamespace(ns), error = function(e) .GlobalEnv) + envir <- tryCatch({ + if (!ns %in% loadedNamespaces()) stop("no") + asNamespace(ns) + }, error = function(e) .GlobalEnv) cl <- trimws(format(call)) if (length(cl) > 1) { cl <- paste0(cl[1], " ", cli::symbol$ellipsis) } # Older cli does not have 'envir'. @@ -935,18 +971,18 @@ err <- local({ srcref <- if ("srcref" %in% names(x) || "procsrfref" %in% names(x)) { vapply( seq_len(nrow(x)), - function(i) format_srcref_plain(x$call[[i]], x$procsrcref[[i]] %||% x$srcref[[i]]), + function(i) format_srcref_plain(x[["call"]][[i]], x$procsrcref[[i]] %||% x$srcref[[i]]), character(1) ) } else { - unname(vapply(x$call, format_srcref_plain, character(1))) + unname(vapply(x[["call"]], format_srcref_plain, character(1))) } lines <- paste0( paste0(format(x$num), ". "), ifelse (visible, "", "| "), scope, - vapply(x$call, format_trace_call_plain, character(1)), + vapply(x[["call"]], format_trace_call_plain, character(1)), srcref ) @@ -959,7 +995,7 @@ err <- local({ format_header_line_plain <- function(x, prefix = NULL) { p_error <- format_error_heading_plain(x, prefix) - p_call <- format_call_plain(x$call) + p_call <- format_call_plain(x[["call"]]) p_srcref <- format_srcref_plain(conditionCall(x), x$procsrcref %||% x$srcref) paste0(p_error, p_call, p_srcref, if (!is.null(conditionCall(x))) ":") } @@ -1026,15 +1062,15 @@ err <- local({ process_call <- function(cond) { cond[c("call", "srcref", "procsrcref")] <- list( - call = if (is.null(cond$call)) { + call = if (is.null(cond[["call"]])) { NULL - } else if (is.character(cond$call)) { - cond$call + } else if (is.character(cond[["call"]])) { + cond[["call"]] } else { - deparse(cond$call, nlines = 2) + deparse(cond[["call"]], nlines = 2) }, srcref = NULL, - procsrcref = get_srcref(cond$call, cond$procsrcref %||% cond$srcref) + procsrcref = get_srcref(cond[["call"]], cond$procsrcref %||% cond$srcref) ) cond } @@ -1139,6 +1175,7 @@ err <- local({ add_trace_back = add_trace_back, process_call = process_call, onload_hook = onload_hook, + is_interactive = is_interactive, format = list( advice = format_advice, call = format_call, From c66419c0710cfe547cf63ea1d3ccb2dedda87775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 22 Feb 2023 12:13:00 +0100 Subject: [PATCH 34/67] Manual: link to [inline-markup] where appropriate Closes #585. --- R/bullets.R | 4 +++ R/cli.R | 23 ++++++++++++++++- R/cliapp-docs.R | 6 ++++- R/format-conditions.R | 2 ++ R/progress-along.R | 4 ++- R/progress-bar.R | 1 + R/progress-client.R | 12 +++++++++ R/progress-server.R | 1 + R/progress-utils.R | 3 +-- R/progress-variables.R | 1 + R/rlang.R | 2 ++ R/status-bar.R | 10 ++++++-- man/cli_abort.Rd | 27 ++++++++++++++++++++ man/cli_alert.Rd | 27 ++++++++++++++++++++ man/cli_blockquote.Rd | 27 ++++++++++++++++++++ man/cli_bullets.Rd | 27 ++++++++++++++++++++ man/cli_bullets_raw.Rd | 26 +++++++++++++++++++ man/cli_dl.Rd | 27 ++++++++++++++++++++ man/cli_h1.Rd | 27 ++++++++++++++++++++ man/cli_li.Rd | 27 ++++++++++++++++++++ man/cli_ol.Rd | 27 ++++++++++++++++++++ man/cli_process_start.Rd | 26 +++++++++++++++++++ man/cli_progress_along.Rd | 37 +++++++++++++++++++++++++++ man/cli_progress_bar.Rd | 37 +++++++++++++++++++++++++++ man/cli_progress_builtin_handlers.Rd | 12 +++++++++ man/cli_progress_message.Rd | 37 +++++++++++++++++++++++++++ man/cli_progress_output.Rd | 38 ++++++++++++++++++++++++++++ man/cli_progress_step.Rd | 38 ++++++++++++++++++++++++++++ man/cli_progress_styles.Rd | 12 +++++++++ man/cli_rule.Rd | 27 ++++++++++++++++++++ man/cli_status.Rd | 26 +++++++++++++++++++ man/cli_status_update.Rd | 26 +++++++++++++++++++ man/cli_text.Rd | 27 ++++++++++++++++++++ man/cli_ul.Rd | 27 ++++++++++++++++++++ man/format_error.Rd | 27 ++++++++++++++++++++ man/format_inline.Rd | 27 ++++++++++++++++++++ man/inline-markup.Rd | 3 ++- man/progress-utils.Rd | 13 +++++++++- man/progress-variables.Rd | 12 +++++++++ 39 files changed, 754 insertions(+), 9 deletions(-) diff --git a/R/bullets.R b/R/bullets.R index 5d241e878..100db4f58 100644 --- a/R/bullets.R +++ b/R/bullets.R @@ -46,6 +46,8 @@ #' @param class Optional additional class(es) for the `div.bullets` element. #' @param .envir Environment to evaluate the glue expressions in. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_bullets <- function(text, id = NULL, class = NULL, @@ -75,7 +77,9 @@ cli_bullets <- function(text, id = NULL, class = NULL, #' @param id Optional id of the `div.bullets` element, can be used in themes. #' @param class Optional additional class(es) for the `div.bullets` element. #' +#' @seealso These functions support [inline markup][inline-markup]. #' @seealso See [cli_bullets()] for examples. +#' @family functions supporting inline markup #' @export cli_bullets_raw <- function(text, id = NULL, class = NULL) { diff --git a/R/cli.R b/R/cli.R index 24c26743a..bffc22666 100644 --- a/R/cli.R +++ b/R/cli.R @@ -106,6 +106,8 @@ cli_fmt <- function(expr, collapse = FALSE, strip_newline = FALSE) { #' and form feeds) as is in the input. #' @return Character scalar, the formatted string. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export #' @examples #' format_inline("A message for {.emph later}, thanks {.fn format_inline}.") @@ -199,6 +201,8 @@ format_inline <- function(..., .envir = parent.frame(), collapse = TRUE, #' concatenated into a single string. Newlines are _not_ preserved. #' @param .envir Environment to evaluate the glue expressions in. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_text <- function(..., .envir = parent.frame()) { @@ -266,6 +270,8 @@ cli_verbatim <- function(..., .envir = parent.frame()) { #' themes. #' @param .envir Environment to evaluate the glue expressions in. #' +#' @seealso These functions supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_h1 <- function(text, id = NULL, class = NULL, .envir = parent.frame()) { @@ -490,6 +496,8 @@ cli_end <- function(id = NULL) { #' @inheritParams cli_div #' @return The id of the new container element, invisibly. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export @@ -555,6 +563,8 @@ cli_ul <- function(items = NULL, id = NULL, class = NULL, #' @inheritParams cli_ul #' @return The id of the new container element, invisibly. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_ol <- function(items = NULL, id = NULL, class = NULL, @@ -605,6 +615,8 @@ cli_ol <- function(items = NULL, id = NULL, class = NULL, #' @inheritParams cli_ul #' @return The id of the new container element, invisibly. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_dl <- function(items = NULL, labels = names(items), id = NULL, @@ -658,6 +670,8 @@ cli_dl <- function(items = NULL, labels = names(items), id = NULL, #' @inheritParams cli_div #' @return The id of the new container element, invisibly. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_li <- function(items = NULL, labels = names(items), id = NULL, @@ -725,6 +739,8 @@ cli_li <- function(items = NULL, labels = names(items), id = NULL, #' @param wrap Whether to auto-wrap the text of the alert. #' @param .envir Environment to evaluate the glue expressions in. #' +#' @seealso These functions supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_alert <- function(text, id = NULL, class = NULL, wrap = FALSE, @@ -840,6 +856,8 @@ cli_alert_info <- function(text, id = NULL, class = NULL, wrap = FALSE, #' @inheritParams rule #' @inheritParams cli_div #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_rule <- function(left = "", center = "", right = "", id = NULL, @@ -865,11 +883,14 @@ cli_rule <- function(left = "", center = "", right = "", id = NULL, #' cli_blockquote(evil, citation = "Donald Ervin Knuth") #' ``` #' -#' @export #' @param quote Text of the quotation. #' @param citation Source of the quotation, typically a link or the name #' of a person. #' @inheritParams cli_div +#' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family functions supporting inline markup +#' @export cli_blockquote <- function(quote, citation = NULL, id = NULL, class = NULL, .envir = parent.frame()) { diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index cb863ffb1..f55fc8777 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -1,5 +1,9 @@ -#' About inline markup in the semantic cli +#' @title About inline markup in the semantic cli +#' +#' @description +#' To learn how to use cli’s semantic markup, start with the ‘Building +#' a semantic CLI’ article at . #' #' @section Command substitution: #' diff --git a/R/format-conditions.R b/R/format-conditions.R index 7e9110c25..772f40d51 100644 --- a/R/format-conditions.R +++ b/R/format-conditions.R @@ -27,6 +27,8 @@ #' @param message It is formatted via a call to [cli_bullets()]. #' @param .envir Environment to evaluate the glue expressions in. #' +#' @seealso These functions support [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export format_error <- function(message, .envir = parent.frame()) { diff --git a/R/progress-along.R b/R/progress-along.R index 735c69e20..ec4d6b653 100644 --- a/R/progress-along.R +++ b/R/progress-along.R @@ -91,8 +91,10 @@ #' @return An index vector from 1 to `length(x)` that triggers progress #' updates as you iterate over it. #' +#' @seealso This function supports [inline markup][inline-markup]. #' @seealso [cli_progress_bar()] and the traditional progress bar API. -#' +#' @family progress bar functions +#' @family functions supporting inline markup #' @export cli_progress_along <- function(x, diff --git a/R/progress-bar.R b/R/progress-bar.R index 12075764a..fdad17af7 100644 --- a/R/progress-bar.R +++ b/R/progress-bar.R @@ -67,6 +67,7 @@ progress_style <- function(x) { #' @return A named list with sublists containing elements #' `complete`, `incomplete` and potentially `current`. #' +#' @family progress bar functions #' @export cli_progress_styles <- function() { diff --git a/R/progress-client.R b/R/progress-client.R index 3494590fb..549250968 100644 --- a/R/progress-client.R +++ b/R/progress-client.R @@ -294,8 +294,11 @@ #' @return `cli_progress_bar()` returns the id of the new progress bar. #' The id is a string constant. #' +#' @seealso These functions support [inline markup][inline-markup]. #' @seealso [cli_progress_message()] and [cli_progress_step()] for simpler #' progress messages. +#' @family progress bar functions +#' @family functions supporting inline markup #' @aliases __cli_update_due cli_tick_reset ccli_tick_reset ticking #' @export @@ -539,6 +542,9 @@ cli_progress_done <- function(id = NULL, .envir = parent.frame(), #' @param .envir Environment to use for glue interpolation of `text`. #' @return `TRUE`, always. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family progress bar functions +#' @family functions supporting inline markup #' @export cli_progress_output <- function(text, id = NULL, .envir = parent.frame()) { @@ -608,8 +614,11 @@ cli_progress_output <- function(text, id = NULL, .envir = parent.frame()) { #' #' @return The id of the new progress bar. #' +#' @seealso This function supports [inline markup][inline-markup]. #' @seealso [cli_progress_bar()] for the complete progress bar API. #' [cli_progress_step()] for a similar display that is styled by default. +#' @family progress bar functions +#' @family functions supporting inline markup #' @export cli_progress_message <- function(msg, @@ -757,6 +766,9 @@ cli_progress_message <- function(msg, #' @param .envir Passed to [cli_progress_bar()]. #' @param ... Passed to [cli_progress_bar()]. #' +#' @seealso This function supports [inline markup][inline-markup]. +#' @family progress bar functions +#' @family functions supporting inline markup #' @export cli_progress_step <- function(msg, diff --git a/R/progress-server.R b/R/progress-server.R index 11043c4c3..2f2d8f509 100644 --- a/R/progress-server.R +++ b/R/progress-server.R @@ -70,6 +70,7 @@ #' @return `cli_progress_builtin_handlers()` returns the names of the #' currently supported progress handlers. #' +#' @family progress bar functions #' @export # TODO: examples diff --git a/R/progress-utils.R b/R/progress-utils.R index 8060fb52b..478040e7c 100644 --- a/R/progress-utils.R +++ b/R/progress-utils.R @@ -6,7 +6,7 @@ #' @return `cli_progress_num()` returns an integer scalar. #' #' @rdname progress-utils -#' @family progress bar +#' @family progress bar functions #' @export cli_progress_num <- function() { @@ -18,7 +18,6 @@ cli_progress_num <- function() { #' @return `cli_progress_cleanup() does not return anything. #' #' @rdname progress-utils -#' @family progress bar #' @export cli_progress_cleanup <- function() { diff --git a/R/progress-variables.R b/R/progress-variables.R index c6d3cd6d7..a81557709 100644 --- a/R/progress-variables.R +++ b/R/progress-variables.R @@ -11,6 +11,7 @@ #' Similarly, in R scripts, you can use `pb_bar` after `library(cli)`, #' or `cli::pb_bar` if you do not attach the cli package. #' +#' @family progress bar functions #' @name progress-variables NULL diff --git a/R/rlang.R b/R/rlang.R index 4973e3660..ce6e79e5b 100644 --- a/R/rlang.R +++ b/R/rlang.R @@ -32,6 +32,8 @@ #' @param .envir Environment to evaluate the glue expressions in. #' @inheritParams rlang::abort #' +#' @seealso These functions support [inline markup][inline-markup]. +#' @family functions supporting inline markup #' @export cli_abort <- function(message, diff --git a/R/status-bar.R b/R/status-bar.R index 22706d9ad..91701a405 100644 --- a/R/status-bar.R +++ b/R/status-bar.R @@ -43,9 +43,11 @@ #' @param .auto_result What to do when auto-closing the status bar. #' @return The id of the new status bar container element, invisibly. #' +#' @seealso Status bars support [inline markup][inline-markup]. #' @seealso The [cli_progress_message()] and [cli_progress_step()] #' functions, for a superior API. #' @family status bar +#' @family functions supporting inline markup #' @export cli_status <- function(msg, msg_done = paste(msg, "... done"), @@ -136,9 +138,11 @@ cli_status_clear <- function(id = NULL, result = c("clear", "done", "failed"), #' @param .envir Environment to evaluate the glue expressions in. #' @return Id of the status bar container. #' -#' @family status bar +#' @seealso This function supports [inline markup][inline-markup]. #' @seealso The [cli_progress_message()] and [cli_progress_step()] #' functions, for a superior API. +#' @family status bar +#' @family functions supporting inline markup #' @export cli_status_update <- function(id = NULL, msg = NULL, msg_done = NULL, @@ -193,9 +197,11 @@ cli_status_update <- function(id = NULL, msg = NULL, msg_done = NULL, #' @inheritParams cli_status #' @return Id of the status bar container. #' -#' @family status bar +#' @seealso This function supports [inline markup][inline-markup]. #' @seealso The [cli_progress_message()] and [cli_progress_step()] #' functions, for a superior API. +#' @family status bar +#' @family functions supporting inline markup #' @export #' @examples #' diff --git a/man/cli_abort.Rd b/man/cli_abort.Rd index dbb14a3f6..25e5e29c1 100644 --- a/man/cli_abort.Rd +++ b/man/cli_abort.Rd @@ -83,3 +83,30 @@ cli_abort(c(
}} } +\seealso{ +These functions support \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_alert.Rd b/man/cli_alert.Rd index 80c4f2805..f1ecd410b 100644 --- a/man/cli_alert.Rd +++ b/man/cli_alert.Rd @@ -123,3 +123,30 @@ cli_alert_info("Data columns: \{.val \{names(mtcars)\}\}.", wrap = TRUE) } } +\seealso{ +These functions supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_blockquote.Rd b/man/cli_blockquote.Rd index c39d4e678..37b13074d 100644 --- a/man/cli_blockquote.Rd +++ b/man/cli_blockquote.Rd @@ -49,3 +49,30 @@ cli_blockquote(evil, citation = "Donald Ervin Knuth") }} } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_bullets.Rd b/man/cli_bullets.Rd index 252b0d397..7793fc86c 100644 --- a/man/cli_bullets.Rd +++ b/man/cli_bullets.Rd @@ -67,3 +67,30 @@ corresponding \verb{bullet-} classes. }} } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_bullets_raw.Rd b/man/cli_bullets_raw.Rd index 4be8515ac..3b3dfba45 100644 --- a/man/cli_bullets_raw.Rd +++ b/man/cli_bullets_raw.Rd @@ -25,5 +25,31 @@ not perform any inline styling or glue substitutions in the input. \code{format_bullets_raw()} returns the output instead of printing it. } \seealso{ +These functions support \link[=inline-markup]{inline markup}. + See \code{\link[=cli_bullets]{cli_bullets()}} for examples. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} diff --git a/man/cli_dl.Rd b/man/cli_dl.Rd index f939760c7..7b5866eea 100644 --- a/man/cli_dl.Rd +++ b/man/cli_dl.Rd @@ -77,3 +77,30 @@ fun() } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_h1.Rd b/man/cli_h1.Rd index b4b3ac08f..a5b3c1e0f 100644 --- a/man/cli_h1.Rd +++ b/man/cli_h1.Rd @@ -42,3 +42,30 @@ cli_h3("Header \{.emph 3\}") }} } +\seealso{ +These functions supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_li.Rd b/man/cli_li.Rd index c96db208b..cbb176164 100644 --- a/man/cli_li.Rd +++ b/man/cli_li.Rd @@ -61,3 +61,30 @@ fun() } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_ol.Rd b/man/cli_ol.Rd index 073e6a490..fe1531ebb 100644 --- a/man/cli_ol.Rd +++ b/man/cli_ol.Rd @@ -101,3 +101,30 @@ fun() } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_process_start.Rd b/man/cli_process_start.Rd index 1645db605..631ebee68 100644 --- a/man/cli_process_start.Rd +++ b/man/cli_process_start.Rd @@ -112,6 +112,8 @@ fun2 <- function() { fun2() } \seealso{ +This function supports \link[=inline-markup]{inline markup}. + The \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} functions, for a superior API. @@ -119,5 +121,29 @@ Other status bar: \code{\link{cli_status_clear}()}, \code{\link{cli_status_update}()}, \code{\link{cli_status}()} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} \concept{status bar} diff --git a/man/cli_progress_along.Rd b/man/cli_progress_along.Rd index a0b16c4ce..88c900ae9 100644 --- a/man/cli_progress_along.Rd +++ b/man/cli_progress_along.Rd @@ -103,5 +103,42 @@ or right after the loop: } } \seealso{ +This function supports \link[=inline-markup]{inline markup}. + \code{\link[=cli_progress_bar]{cli_progress_bar()}} and the traditional progress bar API. + +Other progress bar functions: +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} +\concept{progress bar functions} diff --git a/man/cli_progress_bar.Rd b/man/cli_progress_bar.Rd index dbe23e30f..8bf2ba299 100644 --- a/man/cli_progress_bar.Rd +++ b/man/cli_progress_bar.Rd @@ -361,6 +361,43 @@ fun(paste0("https://acme.com/data-", 1:10, ".zip")) } } \seealso{ +These functions support \link[=inline-markup]{inline markup}. + \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} for simpler progress messages. + +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} +\concept{progress bar functions} diff --git a/man/cli_progress_builtin_handlers.Rd b/man/cli_progress_builtin_handlers.Rd index 86ffb63de..7a086be6e 100644 --- a/man/cli_progress_builtin_handlers.Rd +++ b/man/cli_progress_builtin_handlers.Rd @@ -84,3 +84,15 @@ This handler is available if a shiny app is running. } } +\seealso{ +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} +} +\concept{progress bar functions} diff --git a/man/cli_progress_message.Rd b/man/cli_progress_message.Rd index 5c4ca75e4..9aa3fb679 100644 --- a/man/cli_progress_message.Rd +++ b/man/cli_progress_message.Rd @@ -60,6 +60,43 @@ fun() \if{html}{\figure{progress-message.svg}} } \seealso{ +This function supports \link[=inline-markup]{inline markup}. + \code{\link[=cli_progress_bar]{cli_progress_bar()}} for the complete progress bar API. \code{\link[=cli_progress_step]{cli_progress_step()}} for a similar display that is styled by default. + +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} +\concept{progress bar functions} diff --git a/man/cli_progress_output.Rd b/man/cli_progress_output.Rd index 0fdeb6361..ce43e33d9 100644 --- a/man/cli_progress_output.Rd +++ b/man/cli_progress_output.Rd @@ -43,3 +43,41 @@ fun() \if{html}{\figure{progress-output2.svg}} } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} +\concept{progress bar functions} diff --git a/man/cli_progress_step.Rd b/man/cli_progress_step.Rd index d56d7650c..8e69d39be 100644 --- a/man/cli_progress_step.Rd +++ b/man/cli_progress_step.Rd @@ -142,3 +142,41 @@ f() \if{html}{\figure{progress-step-msg.svg}} } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} +\concept{progress bar functions} diff --git a/man/cli_progress_styles.Rd b/man/cli_progress_styles.Rd index d69ae9a34..cde200d3e 100644 --- a/man/cli_progress_styles.Rd +++ b/man/cli_progress_styles.Rd @@ -43,3 +43,15 @@ options(cli.progress_var_style = NULL) }} } +\seealso{ +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{progress-variables}} +} +\concept{progress bar functions} diff --git a/man/cli_rule.Rd b/man/cli_rule.Rd index 82ac32af7..c18e4db4e 100644 --- a/man/cli_rule.Rd +++ b/man/cli_rule.Rd @@ -68,3 +68,30 @@ cli_end(d) } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_status.Rd b/man/cli_status.Rd index 0ecfae2f1..070589d3d 100644 --- a/man/cli_status.Rd +++ b/man/cli_status.Rd @@ -66,6 +66,8 @@ again. cli automates much of this, via the \code{msg_done}, \code{msg_failed}, a \code{.auto_result} arguments. See examples below. } \seealso{ +Status bars support \link[=inline-markup]{inline markup}. + The \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} functions, for a superior API. @@ -73,5 +75,29 @@ Other status bar: \code{\link{cli_process_start}()}, \code{\link{cli_status_clear}()}, \code{\link{cli_status_update}()} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} \concept{status bar} diff --git a/man/cli_status_update.Rd b/man/cli_status_update.Rd index 35e8b89db..04f5d17dc 100644 --- a/man/cli_status_update.Rd +++ b/man/cli_status_update.Rd @@ -38,6 +38,8 @@ because they have a better default behavior.} Update the status bar } \seealso{ +This function supports \link[=inline-markup]{inline markup}. + The \code{\link[=cli_progress_message]{cli_progress_message()}} and \code{\link[=cli_progress_step]{cli_progress_step()}} functions, for a superior API. @@ -45,5 +47,29 @@ Other status bar: \code{\link{cli_process_start}()}, \code{\link{cli_status_clear}()}, \code{\link{cli_status}()} + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} } +\concept{functions supporting inline markup} \concept{status bar} diff --git a/man/cli_text.Rd b/man/cli_text.Rd index 592fd4735..4b1758a7f 100644 --- a/man/cli_text.Rd +++ b/man/cli_text.Rd @@ -126,3 +126,30 @@ cli_end(ul) } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/cli_ul.Rd b/man/cli_ul.Rd index 40eaa986d..a5f13b3ff 100644 --- a/man/cli_ul.Rd +++ b/man/cli_ul.Rd @@ -76,3 +76,30 @@ fun() } } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{format_error}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/format_error.Rd b/man/format_error.Rd index 4ddc8d936..b09790fba 100644 --- a/man/format_error.Rd +++ b/man/format_error.Rd @@ -52,3 +52,30 @@ stop(format_error(c( }} } +\seealso{ +These functions support \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_inline}()} +} +\concept{functions supporting inline markup} diff --git a/man/format_inline.Rd b/man/format_inline.Rd index d2ad106b2..673f82d1d 100644 --- a/man/format_inline.Rd +++ b/man/format_inline.Rd @@ -35,3 +35,30 @@ it to the screen. It uses \code{\link[=cli_text]{cli_text()}} internally. \examples{ format_inline("A message for {.emph later}, thanks {.fn format_inline}.") } +\seealso{ +This function supports \link[=inline-markup]{inline markup}. + +Other functions supporting inline markup: +\code{\link{cli_abort}()}, +\code{\link{cli_alert}()}, +\code{\link{cli_blockquote}()}, +\code{\link{cli_bullets_raw}()}, +\code{\link{cli_bullets}()}, +\code{\link{cli_dl}()}, +\code{\link{cli_h1}()}, +\code{\link{cli_li}()}, +\code{\link{cli_ol}()}, +\code{\link{cli_process_start}()}, +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_rule}}, +\code{\link{cli_status_update}()}, +\code{\link{cli_status}()}, +\code{\link{cli_text}()}, +\code{\link{cli_ul}()}, +\code{\link{format_error}()} +} +\concept{functions supporting inline markup} diff --git a/man/inline-markup.Rd b/man/inline-markup.Rd index 9b265e0d5..b2c1e5d07 100644 --- a/man/inline-markup.Rd +++ b/man/inline-markup.Rd @@ -4,7 +4,8 @@ \alias{inline-markup} \title{About inline markup in the semantic cli} \description{ -About inline markup in the semantic cli +To learn how to use cli’s semantic markup, start with the ‘Building +a semantic CLI’ article at \url{https://cli.r-lib.org}. } \section{Command substitution}{ diff --git a/man/progress-utils.Rd b/man/progress-utils.Rd index d811f34d4..d9a2a3f75 100644 --- a/man/progress-utils.Rd +++ b/man/progress-utils.Rd @@ -25,4 +25,15 @@ bars created in C/C++ code.) \code{cli_progress_cleanup()} terminates all active progress bars. (It currently ignores progress bars created in the C/C++ code.) } -\concept{progress bar} +\seealso{ +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()}, +\code{\link{progress-variables}} +} +\concept{progress bar functions} diff --git a/man/progress-variables.Rd b/man/progress-variables.Rd index cb95f1294..2d2236466 100644 --- a/man/progress-variables.Rd +++ b/man/progress-variables.Rd @@ -424,3 +424,15 @@ bytes, in a human readable format. } } +\seealso{ +Other progress bar functions: +\code{\link{cli_progress_along}()}, +\code{\link{cli_progress_bar}()}, +\code{\link{cli_progress_builtin_handlers}()}, +\code{\link{cli_progress_message}()}, +\code{\link{cli_progress_num}()}, +\code{\link{cli_progress_output}()}, +\code{\link{cli_progress_step}()}, +\code{\link{cli_progress_styles}()} +} +\concept{progress bar functions} From a740a2ad7e3b7ece27d5f4ac3f9977cd948b6f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 1 Mar 2023 17:57:00 +0100 Subject: [PATCH 35/67] Fix hyperlink support detection in RStudio The RSTUDIO_CLI_HYPERLINKS env var should only be used if we are in a pane with hyperlink support. --- R/ansi-hyperlink.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/ansi-hyperlink.R b/R/ansi-hyperlink.R index e8b4ae6a3..d83210c86 100644 --- a/R/ansi-hyperlink.R +++ b/R/ansi-hyperlink.R @@ -335,10 +335,6 @@ ansi_has_hyperlink_support <- function() { if (!is.na(cray_opt) && !cray_opt) return(FALSE) if (!is.na(Sys.getenv("NO_COLOR", NA_character_))) return(FALSE) - ## environment variable used by RStudio - enabled <- Sys.getenv("RSTUDIO_CLI_HYPERLINKS", "") - if (isTRUE(as.logical(enabled))){ return(TRUE) } - ## Are we in RStudio? rstudio <- rstudio_detect() if (rstudio$type != "not_rstudio") { return(rstudio$hyperlink) } From 45782024b787940b157b1698f8b9a5552294aaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 1 Mar 2023 17:57:57 +0100 Subject: [PATCH 36/67] Turn off hyperlinks in the RStudio render pane Closes #581. --- R/aab-rstudio-detect.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/aab-rstudio-detect.R b/R/aab-rstudio-detect.R index 507e8bb4e..8942089c3 100644 --- a/R/aab-rstudio-detect.R +++ b/R/aab-rstudio-detect.R @@ -275,7 +275,7 @@ rstudio <- local({ ansi_tty = FALSE, ansi_color = FALSE, num_colors = 1L, - hyperlink = data$envs[["RSTUDIO_CLI_HYPERLINKS"]] != "", + hyperlink = FALSE, has_canonical_mode = FALSE ) } From aba4917ed2d48cb0cfc4e09735bdf32d19ccb9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 1 Mar 2023 18:14:07 +0100 Subject: [PATCH 37/67] Remove test case that is not needed any more --- tests/testthat/test-ansi-hyperlink.R | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/testthat/test-ansi-hyperlink.R b/tests/testthat/test-ansi-hyperlink.R index 5edf22c2f..ed4feda5b 100644 --- a/tests/testthat/test-ansi-hyperlink.R +++ b/tests/testthat/test-ansi-hyperlink.R @@ -299,11 +299,6 @@ test_that("ansi_has_hyperlink_support", { expect_false(ansi_has_hyperlink_support()) ) - # rstudio env var - withr::with_envvar(list(RSTUDIO_CLI_HYPERLINKS = "true"), - expect_true(ansi_has_hyperlink_support()) - ) - # are we in rstudio with support? mockery::stub(ansi_has_hyperlink_support, "rstudio_detect", list(type = "rstudio_console", hyperlink = TRUE)) From 42991b582058c3a1b70899e3635d9e34a115f475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 1 Mar 2023 19:51:28 +0100 Subject: [PATCH 38/67] Turn off ANSI hyperlinks if we don't have ANSI colors If we don't have colors, then we probably don't have hyperlink support, either. --- R/ansi-hyperlink.R | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/R/ansi-hyperlink.R b/R/ansi-hyperlink.R index d83210c86..1a5035705 100644 --- a/R/ansi-hyperlink.R +++ b/R/ansi-hyperlink.R @@ -327,13 +327,7 @@ ansi_has_hyperlink_support <- function() { if (isTRUE(as.logical(enabled))){ return(TRUE) } ## If ANSI support is off, then this is off as well - opt <- as.integer(getOption("cli.num_colors", NULL))[1] - if (!is.na(opt) && opt == 1) return(FALSE) - env <- as.integer(Sys.getenv("R_CLI_NUM_COLORS", ""))[1] - if (!is.na(env) && env == 1) return(FALSE) - cray_opt <- as.logical(getOption("crayon.enabled", NULL))[1] - if (!is.na(cray_opt) && !cray_opt) return(FALSE) - if (!is.na(Sys.getenv("NO_COLOR", NA_character_))) return(FALSE) + if (num_ansi_colors() == 1) return(FALSE) ## Are we in RStudio? rstudio <- rstudio_detect() From 79119446955972eaadb07397764c8c039ef6e0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 1 Mar 2023 20:13:19 +0100 Subject: [PATCH 39/67] Fix test cases for hyperlink detection changes --- tests/testthat/test-ansi-hyperlink.R | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-ansi-hyperlink.R b/tests/testthat/test-ansi-hyperlink.R index ed4feda5b..ba28798a9 100644 --- a/tests/testthat/test-ansi-hyperlink.R +++ b/tests/testthat/test-ansi-hyperlink.R @@ -286,20 +286,11 @@ test_that("ansi_has_hyperlink_support", { ) # if no ansi support, then no - withr::with_options(list(cli.num_colors = 1), - expect_false(ansi_has_hyperlink_support()) - ) - withr::with_envvar(list(R_CLI_NUM_COLORS = "1"), - expect_false(ansi_has_hyperlink_support()) - ) - withr::with_options(list(crayon.enabled = FALSE), - expect_false(ansi_has_hyperlink_support()) - ) - withr::with_envvar(list(NO_COLOR = "true"), - expect_false(ansi_has_hyperlink_support()) - ) + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) + expect_false(ansi_has_hyperlink_support()) # are we in rstudio with support? + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "rstudio_detect", list(type = "rstudio_console", hyperlink = TRUE)) expect_true(ansi_has_hyperlink_support()) @@ -307,6 +298,7 @@ test_that("ansi_has_hyperlink_support", { test_that("ansi_has_hyperlink_support 2", { local_clean_cli_context() + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "isatty", FALSE) expect_false(ansi_has_hyperlink_support()) @@ -314,6 +306,7 @@ test_that("ansi_has_hyperlink_support 2", { test_that("ansi_has_hyperlink_support 3", { local_clean_cli_context() + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "isatty", TRUE) mockery::stub(ansi_has_hyperlink_support, "is_windows", TRUE) @@ -323,6 +316,7 @@ test_that("ansi_has_hyperlink_support 3", { test_that("ansi_has_hyperlink_support 4", { local_clean_cli_context() + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "isatty", TRUE) withr::local_envvar("CI" = "true") @@ -334,6 +328,7 @@ test_that("ansi_has_hyperlink_support 4", { test_that("ansi_has_hyperlink_support 5", { local_clean_cli_context() + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "isatty", TRUE) withr::local_envvar( @@ -345,6 +340,7 @@ test_that("ansi_has_hyperlink_support 5", { test_that("ansi_has_hyperlink_support 5", { local_clean_cli_context() + mockery::stub(ansi_has_hyperlink_support, "num_ansi_colors", 256L) mockery::stub(ansi_has_hyperlink_support, "isatty", TRUE) withr::local_envvar(VTE_VERSION = "0.51.1") From 35d102777b38f6e76d0b3eb09dad36deef201258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 22 Mar 2023 14:20:54 +0100 Subject: [PATCH 40/67] Update NEWS --- NEWS.md | 2 ++ man/figures/demo-spinners.svg | 2 +- man/figures/get-spinner.svg | 2 +- man/figures/make-spinner-custom.svg | 2 +- man/figures/make-spinner-default.svg | 2 +- man/figures/make-spinner-template.svg | 2 +- man/figures/progress-1.svg | 2 +- man/figures/progress-after.svg | 2 +- man/figures/progress-along-1.svg | 2 +- man/figures/progress-along-2.svg | 2 +- man/figures/progress-along-3.svg | 2 +- man/figures/progress-clear.svg | 2 +- man/figures/progress-current.svg | 2 +- man/figures/progress-format.svg | 2 +- man/figures/progress-message.svg | 2 +- man/figures/progress-natotal.svg | 2 +- man/figures/progress-output.svg | 2 +- man/figures/progress-output2.svg | 2 +- man/figures/progress-step-dynamic.svg | 2 +- man/figures/progress-step-msg.svg | 2 +- man/figures/progress-step-spin.svg | 2 +- man/figures/progress-step.svg | 2 +- man/figures/progress-tasks.svg | 2 +- 23 files changed, 24 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index c8a1f19c7..5e4f855d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # cli (development version) +* ANSI hyperlinks are now turned off on the RStudio render plane (#581). + # cli 3.6.0 * The progressr progress handler now reports progress correctly diff --git a/man/figures/demo-spinners.svg b/man/figures/demo-spinners.svg index 6f3a9943b..cb2dffd8a 100644 --- a/man/figures/demo-spinners.svg +++ b/man/figures/demo-spinners.svg @@ -1 +1 @@ -🕐🕐clock🕑clock🕒clock🕓clock🕔clock🕕clock🕖clock🕗clock🕘clock🕙clock🕚clock \ No newline at end of file +🕛🕛clock🕐clock🕑clock🕒clock🕓clock🕔clock🕕clock🕖clock🕗clock🕘clock🕙clock🕚clock \ No newline at end of file diff --git a/man/figures/get-spinner.svg b/man/figures/get-spinner.svg index e5aa12be5..7c1eccccf 100644 --- a/man/figures/get-spinner.svg +++ b/man/figures/get-spinner.svg @@ -1 +1 @@ -❤️Spinning100done(22/s)|4.6s💙Spinning1done(22/s)|46ms💜Spinning3done(21/s)|141ms💚Spinning7done(22/s)|323ms❤️Spinning11done(21/s)|516ms💛Spinning16done(21/s)|746ms💙Spinning20done(22/s)|928ms💜Spinning25done(22/s)|1.2s💚Spinning29done(22/s)|1.3s❤️Spinning34done(22/s)|1.6s💛Spinning38done(22/s)|1.8s💙Spinning42done(22/s)|1.9s💜Spinning47done(22/s)|2.2s💚Spinning51done(22/s)|2.4s❤️Spinning55done(22/s)|2.5s💛Spinning60done(22/s)|2.8s💙Spinning64done(22/s)|3s💜Spinning69done(22/s)|3.2s💚Spinning73done(22/s)|3.4s❤️Spinning78done(22/s)|3.6s💛Spinning82done(22/s)|3.8s💙Spinning86done(22/s)|4s💜Spinning91done(22/s)|4.2s💚Spinning95done(22/s)|4.4s \ No newline at end of file +❤️Spinning100done(21/s)|4.8s💙Spinning1done(22/s)|46ms💜Spinning2done(21/s)|94ms💚Spinning7done(22/s)|324ms❤️Spinning11done(21/s)|521ms💛Spinning15done(21/s)|721ms💙Spinning19done(21/s)|920ms💜Spinning24done(21/s)|1.2s💚Spinning28done(21/s)|1.3s❤️Spinning32done(21/s)|1.5s💛Spinning36done(21/s)|1.7s💙Spinning41done(21/s)|2s💜Spinning45done(21/s)|2.2s💚Spinning49done(21/s)|2.3s❤️Spinning54done(21/s)|2.6s💛Spinning58done(21/s)|2.8s💙Spinning62done(21/s)|3s💜Spinning67done(21/s)|3.2s💚Spinning71done(21/s)|3.4s❤️Spinning75done(21/s)|3.6s💛Spinning79done(21/s)|3.8s💙Spinning84done(21/s)|4s💜Spinning88done(21/s)|4.2s💚Spinning92done(21/s)|4.4s❤️Spinning96done(21/s)|4.6s \ No newline at end of file diff --git a/man/figures/make-spinner-custom.svg b/man/figures/make-spinner-custom.svg index 13e8aa3a7..bb5cc8393 100644 --- a/man/figures/make-spinner-custom.svg +++ b/man/figures/make-spinner-custom.svg @@ -1 +1 @@ -Downloading.Downloading..Downloading...Downloading..Downloading.Downloading \ No newline at end of file +Downloading.Downloading..Downloading...Downloading..Downloading.Downloading \ No newline at end of file diff --git a/man/figures/make-spinner-default.svg b/man/figures/make-spinner-default.svg index 8b168c0f1..1dbc62bb7 100644 --- a/man/figures/make-spinner-default.svg +++ b/man/figures/make-spinner-default.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/man/figures/make-spinner-template.svg b/man/figures/make-spinner-template.svg index 6a2cad979..3ec97ebc2 100644 --- a/man/figures/make-spinner-template.svg +++ b/man/figures/make-spinner-template.svg @@ -1 +1 @@ -ComputingComputingComputingComputingComputingComputingComputingComputingComputingComputing \ No newline at end of file +ComputingComputingComputingComputingComputingComputingComputingComputingComputingComputing \ No newline at end of file diff --git a/man/figures/progress-1.svg b/man/figures/progress-1.svg index fa8eebbbb..84ee4c06a 100644 --- a/man/figures/progress-1.svg +++ b/man/figures/progress-1.svg @@ -1 +1 @@ -Cleaningdata███████████████████████████████100%|ETA:0sCleaningdata██████████████████████████████1%|ETA:5sCleaningdata███████████████████████████████5%|ETA:5sCleaningdata███████████████████████████████8%|ETA:5sCleaningdata███████████████████████████████12%|ETA:5sCleaningdata███████████████████████████████15%|ETA:5sCleaningdata███████████████████████████████19%|ETA:5sCleaningdata███████████████████████████████22%|ETA:4sCleaningdata███████████████████████████████26%|ETA:4sCleaningdata███████████████████████████████30%|ETA:4sCleaningdata███████████████████████████████33%|ETA:4sCleaningdata███████████████████████████████36%|ETA:4sCleaningdata███████████████████████████████40%|ETA:3sCleaningdata███████████████████████████████44%|ETA:3sCleaningdata███████████████████████████████47%|ETA:3sCleaningdata███████████████████████████████51%|ETA:3sCleaningdata███████████████████████████████54%|ETA:3sCleaningdata███████████████████████████████58%|ETA:2sCleaningdata███████████████████████████████61%|ETA:2sCleaningdata███████████████████████████████65%|ETA:2sCleaningdata███████████████████████████████68%|ETA:2sCleaningdata███████████████████████████████72%|ETA:2sCleaningdata███████████████████████████████75%|ETA:1sCleaningdata███████████████████████████████79%|ETA:1sCleaningdata███████████████████████████████83%|ETA:1sCleaningdata███████████████████████████████86%|ETA:1sCleaningdata███████████████████████████████89%|ETA:1sCleaningdata███████████████████████████████93%|ETA:0sCleaningdata██████████████████████████████97%|ETA:0s \ No newline at end of file +Cleaningdata███████████████████████████████100%|ETA:0sCleaningdata███████████████████████████████3%|ETA:5sCleaningdata███████████████████████████████7%|ETA:5sCleaningdata███████████████████████████████10%|ETA:5sCleaningdata███████████████████████████████14%|ETA:5sCleaningdata███████████████████████████████17%|ETA:5sCleaningdata███████████████████████████████20%|ETA:5sCleaningdata███████████████████████████████24%|ETA:4sCleaningdata███████████████████████████████27%|ETA:4sCleaningdata███████████████████████████████31%|ETA:4sCleaningdata███████████████████████████████34%|ETA:4sCleaningdata███████████████████████████████38%|ETA:4sCleaningdata███████████████████████████████41%|ETA:3sCleaningdata███████████████████████████████45%|ETA:3sCleaningdata███████████████████████████████48%|ETA:3sCleaningdata███████████████████████████████51%|ETA:3sCleaningdata███████████████████████████████55%|ETA:3sCleaningdata███████████████████████████████58%|ETA:2sCleaningdata███████████████████████████████62%|ETA:2sCleaningdata███████████████████████████████65%|ETA:2sCleaningdata███████████████████████████████69%|ETA:2sCleaningdata███████████████████████████████72%|ETA:2sCleaningdata███████████████████████████████76%|ETA:1sCleaningdata███████████████████████████████79%|ETA:1sCleaningdata███████████████████████████████83%|ETA:1sCleaningdata███████████████████████████████87%|ETA:1sCleaningdata███████████████████████████████90%|ETA:1sCleaningdata███████████████████████████████94%|ETA:0sCleaningdata██████████████████████████████97%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-after.svg b/man/figures/progress-after.svg index 8fa62dc6e..c60cffdae 100644 --- a/man/figures/progress-after.svg +++ b/man/figures/progress-after.svg @@ -1 +1 @@ -Startingnow,at2022-08-2219:17:42███████████████████████████████100%@2022-08-2219:17:47███████████████████████████████46%@2022-08-2219:17:44███████████████████████████████47%@2022-08-2219:17:44███████████████████████████████51%@2022-08-2219:17:45███████████████████████████████55%@2022-08-2219:17:45███████████████████████████████60%@2022-08-2219:17:45███████████████████████████████64%@2022-08-2219:17:45███████████████████████████████69%@2022-08-2219:17:45███████████████████████████████73%@2022-08-2219:17:46███████████████████████████████78%@2022-08-2219:17:46███████████████████████████████82%@2022-08-2219:17:46███████████████████████████████86%@2022-08-2219:17:46███████████████████████████████90%@2022-08-2219:17:46███████████████████████████████95%@2022-08-2219:17:47███████████████████████████████99%@2022-08-2219:17:47 \ No newline at end of file +Startingnow,at2022-09-0711:26:44███████████████████████████████100%@2022-09-0711:26:49███████████████████████████████47%@2022-09-0711:26:46███████████████████████████████49%@2022-09-0711:26:46███████████████████████████████53%@2022-09-0711:26:46███████████████████████████████58%@2022-09-0711:26:47███████████████████████████████62%@2022-09-0711:26:47███████████████████████████████67%@2022-09-0711:26:47███████████████████████████████71%@2022-09-0711:26:47███████████████████████████████75%@2022-09-0711:26:48███████████████████████████████80%@2022-09-0711:26:48███████████████████████████████84%@2022-09-0711:26:48███████████████████████████████88%@2022-09-0711:26:48███████████████████████████████92%@2022-09-0711:26:48██████████████████████████████97%@2022-09-0711:26:49 \ No newline at end of file diff --git a/man/figures/progress-along-1.svg b/man/figures/progress-along-1.svg index e430537f8..24d0fbea2 100644 --- a/man/figures/progress-along-1.svg +++ b/man/figures/progress-along-1.svg @@ -1 +1 @@ -Downloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sDownloading0%|ETA:?Downloading■■■6%|ETA:4sDownloading■■■■10%|ETA:4sDownloading■■■■■14%|ETA:4sDownloading■■■■■■■19%|ETA:4sDownloading■■■■■■■■23%|ETA:4sDownloading■■■■■■■■■27%|ETA:3sDownloading■■■■■■■■■■31%|ETA:3sDownloading■■■■■■■■■■■■36%|ETA:3sDownloading■■■■■■■■■■■■■40%|ETA:3sDownloading■■■■■■■■■■■■■■■45%|ETA:3sDownloading■■■■■■■■■■■■■■■■49%|ETA:2sDownloading■■■■■■■■■■■■■■■■■53%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■57%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■61%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■66%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■■70%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■74%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■79%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■83%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■87%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■92%|ETA:0sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■96%|ETA:0s \ No newline at end of file +Downloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sDownloading0%|ETA:?Downloading■■■6%|ETA:4sDownloading■■■■11%|ETA:4sDownloading■■■■■15%|ETA:4sDownloading■■■■■■■19%|ETA:4sDownloading■■■■■■■■24%|ETA:4sDownloading■■■■■■■■■28%|ETA:3sDownloading■■■■■■■■■■■32%|ETA:3sDownloading■■■■■■■■■■■■37%|ETA:3sDownloading■■■■■■■■■■■■■■42%|ETA:3sDownloading■■■■■■■■■■■■■■■46%|ETA:2sDownloading■■■■■■■■■■■■■■■■50%|ETA:2sDownloading■■■■■■■■■■■■■■■■■55%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■59%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■64%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■68%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■72%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■77%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■81%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■85%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■90%|ETA:0sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■94%|ETA:0sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■98%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-along-2.svg b/man/figures/progress-along-2.svg index e65205e3e..89ee14eaf 100644 --- a/man/figures/progress-along-2.svg +++ b/man/figures/progress-along-2.svg @@ -1 +1 @@ -Downloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sDownloading0%|ETA:?Downloading■■■6%|ETA:4sDownloading■■■■10%|ETA:4sDownloading■■■■■14%|ETA:4sDownloading■■■■■■18%|ETA:4sDownloading■■■■■■■■22%|ETA:4sDownloading■■■■■■■■■27%|ETA:3sDownloading■■■■■■■■■■31%|ETA:3sDownloading■■■■■■■■■■■35%|ETA:3sDownloading■■■■■■■■■■■■■39%|ETA:3sDownloading■■■■■■■■■■■■■■44%|ETA:3sDownloading■■■■■■■■■■■■■■■48%|ETA:2sDownloading■■■■■■■■■■■■■■■■■52%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■56%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■61%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■65%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■■69%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■73%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■78%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■82%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■86%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■91%|ETA:0sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■95%|ETA:0s \ No newline at end of file +Downloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■100%|ETA:0sDownloading0%|ETA:?Downloading■■■6%|ETA:4sDownloading■■■■10%|ETA:4sDownloading■■■■■15%|ETA:4sDownloading■■■■■■■19%|ETA:4sDownloading■■■■■■■■23%|ETA:4sDownloading■■■■■■■■■28%|ETA:3sDownloading■■■■■■■■■■■32%|ETA:3sDownloading■■■■■■■■■■■■36%|ETA:3sDownloading■■■■■■■■■■■■■41%|ETA:3sDownloading■■■■■■■■■■■■■■■45%|ETA:3sDownloading■■■■■■■■■■■■■■■■49%|ETA:2sDownloading■■■■■■■■■■■■■■■■■54%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■58%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■62%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■67%|ETA:2sDownloading■■■■■■■■■■■■■■■■■■■■■■71%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■76%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■80%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■84%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■89%|ETA:1sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■93%|ETA:0sDownloading■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■97%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-along-3.svg b/man/figures/progress-along-3.svg index 801b29676..f8586dfd6 100644 --- a/man/figures/progress-along-3.svg +++ b/man/figures/progress-along-3.svg @@ -1 +1 @@ -Downloadingdatafile100Downloadingdatafile0Downloadingdatafile5Downloadingdatafile10Downloadingdatafile15Downloadingdatafile19Downloadingdatafile24Downloadingdatafile29Downloadingdatafile33Downloadingdatafile38Downloadingdatafile43Downloadingdatafile47Downloadingdatafile51Downloadingdatafile56Downloadingdatafile61Downloadingdatafile65Downloadingdatafile70Downloadingdatafile74Downloadingdatafile79Downloadingdatafile84Downloadingdatafile88Downloadingdatafile92Downloadingdatafile97 \ No newline at end of file +Downloadingdatafile100Downloadingdatafile0Downloadingdatafile7Downloadingdatafile11Downloadingdatafile16Downloadingdatafile21Downloadingdatafile25Downloadingdatafile30Downloadingdatafile35Downloadingdatafile39Downloadingdatafile44Downloadingdatafile48Downloadingdatafile53Downloadingdatafile57Downloadingdatafile62Downloadingdatafile66Downloadingdatafile71Downloadingdatafile76Downloadingdatafile81Downloadingdatafile85Downloadingdatafile90Downloadingdatafile95Downloadingdatafile99 \ No newline at end of file diff --git a/man/figures/progress-clear.svg b/man/figures/progress-clear.svg index 09b1dc43f..c3b4ac31b 100644 --- a/man/figures/progress-clear.svg +++ b/man/figures/progress-clear.svg @@ -1 +1 @@ -Parametertuning███████████████████████████████100%|ETA:0sDatacleaning██████████████████████████████1%|ETA:3sDatacleaning███████████████████████████████5%|ETA:3sDatacleaning███████████████████████████████11%|ETA:3sDatacleaning███████████████████████████████16%|ETA:3sDatacleaning███████████████████████████████22%|ETA:3sDatacleaning███████████████████████████████27%|ETA:3sDatacleaning███████████████████████████████33%|ETA:2sDatacleaning███████████████████████████████38%|ETA:2sDatacleaning███████████████████████████████44%|ETA:2sDatacleaning███████████████████████████████49%|ETA:2sDatacleaning███████████████████████████████55%|ETA:2sDatacleaning███████████████████████████████60%|ETA:1sDatacleaning███████████████████████████████66%|ETA:1sDatacleaning███████████████████████████████71%|ETA:1sDatacleaning███████████████████████████████76%|ETA:1sDatacleaning███████████████████████████████82%|ETA:1sDatacleaning███████████████████████████████88%|ETA:0sDatacleaning███████████████████████████████93%|ETA:0sDatacleaning███████████████████████████████99%|ETA:0sParametertuning███████████████████████████████4%|ETA:3sParametertuning███████████████████████████████9%|ETA:3sParametertuning███████████████████████████████15%|ETA:3sParametertuning███████████████████████████████21%|ETA:3sParametertuning███████████████████████████████26%|ETA:3sParametertuning███████████████████████████████31%|ETA:3sParametertuning███████████████████████████████37%|ETA:2sParametertuning███████████████████████████████42%|ETA:2sParametertuning███████████████████████████████48%|ETA:2sParametertuning███████████████████████████████53%|ETA:2sParametertuning███████████████████████████████59%|ETA:2sParametertuning███████████████████████████████64%|ETA:1sParametertuning███████████████████████████████70%|ETA:1sParametertuning███████████████████████████████76%|ETA:1sParametertuning███████████████████████████████81%|ETA:1sParametertuning███████████████████████████████87%|ETA:0sParametertuning███████████████████████████████92%|ETA:0sParametertuning██████████████████████████████97%|ETA:0s \ No newline at end of file +Parametertuning███████████████████████████████100%|ETA:0sDatacleaning██████████████████████████████1%|ETA:3sDatacleaning███████████████████████████████6%|ETA:3sDatacleaning███████████████████████████████11%|ETA:3sDatacleaning███████████████████████████████17%|ETA:3sDatacleaning███████████████████████████████22%|ETA:3sDatacleaning███████████████████████████████28%|ETA:3sDatacleaning███████████████████████████████33%|ETA:2sDatacleaning███████████████████████████████38%|ETA:2sDatacleaning███████████████████████████████44%|ETA:2sDatacleaning███████████████████████████████49%|ETA:2sDatacleaning███████████████████████████████55%|ETA:2sDatacleaning███████████████████████████████60%|ETA:1sDatacleaning███████████████████████████████66%|ETA:1sDatacleaning███████████████████████████████71%|ETA:1sDatacleaning███████████████████████████████77%|ETA:1sDatacleaning███████████████████████████████82%|ETA:1sDatacleaning███████████████████████████████88%|ETA:0sDatacleaning███████████████████████████████94%|ETA:0sDatacleaning███████████████████████████████99%|ETA:0sParametertuning███████████████████████████████4%|ETA:3sParametertuning███████████████████████████████10%|ETA:3sParametertuning███████████████████████████████15%|ETA:3sParametertuning███████████████████████████████21%|ETA:3sParametertuning███████████████████████████████26%|ETA:3sParametertuning███████████████████████████████32%|ETA:2sParametertuning███████████████████████████████38%|ETA:2sParametertuning███████████████████████████████43%|ETA:2sParametertuning███████████████████████████████48%|ETA:2sParametertuning███████████████████████████████54%|ETA:2sParametertuning███████████████████████████████59%|ETA:1sParametertuning███████████████████████████████65%|ETA:1sParametertuning███████████████████████████████70%|ETA:1sParametertuning███████████████████████████████76%|ETA:1sParametertuning███████████████████████████████81%|ETA:1sParametertuning███████████████████████████████87%|ETA:0sParametertuning███████████████████████████████93%|ETA:0sParametertuning██████████████████████████████98%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-current.svg b/man/figures/progress-current.svg index dfabf4188..612af5641 100644 --- a/man/figures/progress-current.svg +++ b/man/figures/progress-current.svg @@ -1 +1 @@ -Firststep███████████████████████████████100%|ETA:0sSecondstep███████████████████████████████100%|ETA:0sFirststep██████████████████████████████1%|ETA:3sFirststep███████████████████████████████9%|ETA:2sFirststep███████████████████████████████16%|ETA:2sFirststep███████████████████████████████24%|ETA:2sFirststep███████████████████████████████31%|ETA:2sFirststep███████████████████████████████39%|ETA:2sFirststep███████████████████████████████47%|ETA:1sFirststep███████████████████████████████55%|ETA:1sFirststep███████████████████████████████63%|ETA:1sFirststep███████████████████████████████70%|ETA:1sFirststep███████████████████████████████78%|ETA:1sFirststep███████████████████████████████86%|ETA:0sFirststep███████████████████████████████93%|ETA:0sSecondstep███████████████████████████████8%|ETA:2sSecondstep███████████████████████████████16%|ETA:2sSecondstep███████████████████████████████23%|ETA:2sSecondstep███████████████████████████████31%|ETA:2sSecondstep███████████████████████████████38%|ETA:2sSecondstep███████████████████████████████45%|ETA:1sSecondstep███████████████████████████████53%|ETA:1sSecondstep███████████████████████████████61%|ETA:1sSecondstep███████████████████████████████69%|ETA:1sSecondstep███████████████████████████████77%|ETA:1sSecondstep███████████████████████████████84%|ETA:0sSecondstep███████████████████████████████92%|ETA:0s \ No newline at end of file +Firststep███████████████████████████████100%|ETA:0sSecondstep███████████████████████████████100%|ETA:0sFirststep██████████████████████████████1%|ETA:3sFirststep███████████████████████████████2%|ETA:3sFirststep███████████████████████████████11%|ETA:2sFirststep███████████████████████████████18%|ETA:2sFirststep███████████████████████████████26%|ETA:2sFirststep███████████████████████████████33%|ETA:2sFirststep███████████████████████████████40%|ETA:2sFirststep███████████████████████████████48%|ETA:1sFirststep███████████████████████████████55%|ETA:1sFirststep███████████████████████████████63%|ETA:1sFirststep███████████████████████████████70%|ETA:1sFirststep███████████████████████████████78%|ETA:1sFirststep███████████████████████████████85%|ETA:0sFirststep███████████████████████████████93%|ETA:0sSecondstep███████████████████████████████7%|ETA:2sSecondstep███████████████████████████████15%|ETA:2sSecondstep███████████████████████████████22%|ETA:2sSecondstep███████████████████████████████30%|ETA:2sSecondstep███████████████████████████████37%|ETA:2sSecondstep███████████████████████████████45%|ETA:1sSecondstep███████████████████████████████53%|ETA:1sSecondstep███████████████████████████████60%|ETA:1sSecondstep███████████████████████████████67%|ETA:1sSecondstep███████████████████████████████74%|ETA:1sSecondstep███████████████████████████████82%|ETA:0sSecondstep███████████████████████████████89%|ETA:0sSecondstep██████████████████████████████97%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-format.svg b/man/figures/progress-format.svg index 3758e1021..963e71af7 100644 --- a/man/figures/progress-format.svg +++ b/man/figures/progress-format.svg @@ -1 +1 @@ -Downloaded10filesin4.7s.Downloadingdata-1.zip[1/10]ETA:0sDownloadingdata-2.zip[2/10]ETA:2sDownloadingdata-3.zip[3/10]ETA:2sDownloadingdata-4.zip[4/10]ETA:2sDownloadingdata-5.zip[5/10]ETA:2sDownloadingdata-6.zip[6/10]ETA:2sDownloadingdata-7.zip[7/10]ETA:1sDownloadingdata-8.zip[8/10]ETA:1sDownloadingdata-9.zip[9/10]ETA:0s \ No newline at end of file +Downloaded10filesin4.7s.Downloadingdata-1.zip[1/10]ETA:0sDownloadingdata-2.zip[2/10]ETA:2sDownloadingdata-3.zip[3/10]ETA:2sDownloadingdata-4.zip[4/10]ETA:2sDownloadingdata-5.zip[5/10]ETA:2sDownloadingdata-6.zip[6/10]ETA:2sDownloadingdata-7.zip[7/10]ETA:1sDownloadingdata-8.zip[8/10]ETA:1sDownloadingdata-9.zip[9/10]ETA:0s \ No newline at end of file diff --git a/man/figures/progress-message.svg b/man/figures/progress-message.svg index 9e9a58326..2b046f210 100644 --- a/man/figures/progress-message.svg +++ b/man/figures/progress-message.svg @@ -1 +1 @@ -Taskthreeisunderway:step1Taskoneisrunning...Tasktwoisrunning...Taskthreeisunderway:step2Taskthreeisunderway:step3Taskthreeisunderway:step4Taskthreeisunderway:step5 \ No newline at end of file +Taskthreeisunderway:step1Taskoneisrunning...Tasktwoisrunning...Taskthreeisunderway:step2Taskthreeisunderway:step3Taskthreeisunderway:step4Taskthreeisunderway:step5 \ No newline at end of file diff --git a/man/figures/progress-natotal.svg b/man/figures/progress-natotal.svg index 8b9ebc4f1..5d3f9d636 100644 --- a/man/figures/progress-natotal.svg +++ b/man/figures/progress-natotal.svg @@ -1 +1 @@ -Parametertuning100done(27/s)|3.7sParametertuning1done(28/s)|36msParametertuning4done(28/s)|142msParametertuning10done(28/s)|354msParametertuning15done(28/s)|541msParametertuning21done(28/s)|758msParametertuning26done(28/s)|941msParametertuning32done(27/s)|1.2sParametertuning37done(28/s)|1.3sParametertuning43done(28/s)|1.6sParametertuning48done(28/s)|1.7sParametertuning54done(28/s)|2sParametertuning60done(28/s)|2.2sParametertuning65done(28/s)|2.3sParametertuning71done(28/s)|2.6sParametertuning77done(28/s)|2.8sParametertuning82done(28/s)|3sParametertuning87done(27/s)|3.2sParametertuning93done(27/s)|3.4sParametertuning98done(27/s)|3.6s \ No newline at end of file +Parametertuning100done(27/s)|3.7sParametertuning1done(28/s)|36msParametertuning4done(28/s)|146msParametertuning9done(27/s)|328msParametertuning15done(28/s)|535msParametertuning21done(28/s)|752msParametertuning27done(28/s)|968msParametertuning32done(28/s)|1.2sParametertuning38done(28/s)|1.4sParametertuning43done(28/s)|1.6sParametertuning49done(28/s)|1.8sParametertuning55done(28/s)|2sParametertuning60done(28/s)|2.2sParametertuning66done(28/s)|2.4sParametertuning72done(28/s)|2.6sParametertuning77done(28/s)|2.8sParametertuning82done(28/s)|3sParametertuning88done(28/s)|3.2sParametertuning93done(27/s)|3.4sParametertuning99done(27/s)|3.6s \ No newline at end of file diff --git a/man/figures/progress-output.svg b/man/figures/progress-output.svg index 71567a201..d29cb891b 100644 --- a/man/figures/progress-output.svg +++ b/man/figures/progress-output.svg @@ -1 +1 @@ -BeforetheprogressbarCalculating███████████████████████████████47%|ETA:2sAlreadyhalfway!Calculating███████████████████████████████100%|ETA:0sAlldoneCalculating██████████████████████████████1%|ETA:4sCalculating███████████████████████████████4%|ETA:4sCalculating███████████████████████████████9%|ETA:4sCalculating███████████████████████████████13%|ETA:4sCalculating███████████████████████████████17%|ETA:4sCalculating███████████████████████████████21%|ETA:4sCalculating███████████████████████████████26%|ETA:3sCalculating███████████████████████████████30%|ETA:3sCalculating███████████████████████████████34%|ETA:3sCalculating███████████████████████████████38%|ETA:3sCalculating███████████████████████████████43%|ETA:3sCalculating███████████████████████████████51%|ETA:2sCalculating███████████████████████████████56%|ETA:2sCalculating███████████████████████████████60%|ETA:2sCalculating███████████████████████████████64%|ETA:2sCalculating███████████████████████████████69%|ETA:1sCalculating███████████████████████████████73%|ETA:1sCalculating███████████████████████████████77%|ETA:1sCalculating███████████████████████████████81%|ETA:1sCalculating███████████████████████████████85%|ETA:1sCalculating███████████████████████████████90%|ETA:0sCalculating███████████████████████████████94%|ETA:0sCalculating██████████████████████████████98%|ETA:0s \ No newline at end of file +BeforetheprogressbarCalculating███████████████████████████████48%|ETA:2sAlreadyhalfway!Calculating███████████████████████████████100%|ETA:0sAlldoneCalculating██████████████████████████████1%|ETA:5sCalculating███████████████████████████████2%|ETA:5sCalculating███████████████████████████████6%|ETA:4sCalculating███████████████████████████████10%|ETA:4sCalculating███████████████████████████████15%|ETA:4sCalculating███████████████████████████████19%|ETA:4sCalculating███████████████████████████████23%|ETA:4sCalculating███████████████████████████████28%|ETA:3sCalculating███████████████████████████████32%|ETA:3sCalculating███████████████████████████████36%|ETA:3sCalculating███████████████████████████████40%|ETA:3sCalculating███████████████████████████████45%|ETA:3sCalculating███████████████████████████████53%|ETA:2sCalculating███████████████████████████████57%|ETA:2sCalculating███████████████████████████████61%|ETA:2sCalculating███████████████████████████████65%|ETA:2sCalculating███████████████████████████████70%|ETA:1sCalculating███████████████████████████████74%|ETA:1sCalculating███████████████████████████████78%|ETA:1sCalculating███████████████████████████████83%|ETA:1sCalculating███████████████████████████████87%|ETA:1sCalculating███████████████████████████████91%|ETA:0sCalculating███████████████████████████████95%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-output2.svg b/man/figures/progress-output2.svg index fb309f5b1..a19eeb72e 100644 --- a/man/figures/progress-output2.svg +++ b/man/figures/progress-output2.svg @@ -1 +1 @@ -BeforetheprogressbarCalculating███████████████████████████████47%|ETA:3sAlreadyhalfway!Calculating███████████████████████████████100%|ETA:0sAlldoneCalculating██████████████████████████████1%|ETA:4sCalculating███████████████████████████████4%|ETA:4sCalculating███████████████████████████████8%|ETA:4sCalculating███████████████████████████████12%|ETA:4sCalculating███████████████████████████████17%|ETA:4sCalculating███████████████████████████████21%|ETA:4sCalculating███████████████████████████████25%|ETA:4sCalculating███████████████████████████████29%|ETA:3sCalculating███████████████████████████████34%|ETA:3sCalculating███████████████████████████████38%|ETA:3sCalculating███████████████████████████████42%|ETA:3sCalculating███████████████████████████████51%|ETA:2sCalculating███████████████████████████████55%|ETA:2sCalculating███████████████████████████████59%|ETA:2sCalculating███████████████████████████████64%|ETA:2sCalculating███████████████████████████████68%|ETA:2sCalculating███████████████████████████████72%|ETA:1sCalculating███████████████████████████████76%|ETA:1sCalculating███████████████████████████████81%|ETA:1sCalculating███████████████████████████████85%|ETA:1sCalculating███████████████████████████████89%|ETA:1sCalculating███████████████████████████████93%|ETA:0sCalculating██████████████████████████████98%|ETA:0s \ No newline at end of file +BeforetheprogressbarCalculating███████████████████████████████50%|ETA:2sAlreadyhalfway!Calculating███████████████████████████████100%|ETA:0sAlldoneCalculating██████████████████████████████1%|ETA:5sCalculating███████████████████████████████2%|ETA:5sCalculating███████████████████████████████6%|ETA:4sCalculating███████████████████████████████11%|ETA:4sCalculating███████████████████████████████15%|ETA:4sCalculating███████████████████████████████19%|ETA:4sCalculating███████████████████████████████24%|ETA:4sCalculating███████████████████████████████28%|ETA:3sCalculating███████████████████████████████32%|ETA:3sCalculating███████████████████████████████37%|ETA:3sCalculating███████████████████████████████41%|ETA:3sCalculating███████████████████████████████46%|ETA:3sCalculating███████████████████████████████55%|ETA:2sCalculating███████████████████████████████59%|ETA:2sCalculating███████████████████████████████64%|ETA:2sCalculating███████████████████████████████68%|ETA:1sCalculating███████████████████████████████72%|ETA:1sCalculating███████████████████████████████76%|ETA:1sCalculating███████████████████████████████81%|ETA:1sCalculating███████████████████████████████85%|ETA:1sCalculating███████████████████████████████89%|ETA:1sCalculating███████████████████████████████93%|ETA:0sCalculating██████████████████████████████98%|ETA:0s \ No newline at end of file diff --git a/man/figures/progress-step-dynamic.svg b/man/figures/progress-step-dynamic.svg index db4f02edd..813f6ba78 100644 --- a/man/figures/progress-step-dynamic.svg +++ b/man/figures/progress-step-dynamic.svg @@ -1 +1 @@ -Downloadingdata,gotfile100/100[2.6s]Importingdata[1s]Cleaningdata[2s]FittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodel[3.5s]DownloadingdataDownloadingdata,gotfile2/100Downloadingdata,gotfile11/100Downloadingdata,gotfile19/100Downloadingdata,gotfile26/100Downloadingdata,gotfile34/100Downloadingdata,gotfile43/100Downloadingdata,gotfile50/100Downloadingdata,gotfile58/100Downloadingdata,gotfile66/100Downloadingdata,gotfile74/100Downloadingdata,gotfile82/100Downloadingdata,gotfile90/100Downloadingdata,gotfile98/100ImportingdataCleaningdataFittingmodelFittingmodel \ No newline at end of file +Downloadingdata,gotfile100/100[2.6s]Importingdata[1s]Cleaningdata[2s]FittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodel[3.5s]DownloadingdataDownloadingdata,gotfile7/100Downloadingdata,gotfile15/100Downloadingdata,gotfile22/100Downloadingdata,gotfile30/100Downloadingdata,gotfile38/100Downloadingdata,gotfile46/100Downloadingdata,gotfile54/100Downloadingdata,gotfile62/100Downloadingdata,gotfile69/100Downloadingdata,gotfile76/100Downloadingdata,gotfile84/100Downloadingdata,gotfile92/100Downloadingdata,gotfile100/100ImportingdataCleaningdataFittingmodelFittingmodel \ No newline at end of file diff --git a/man/figures/progress-step-msg.svg b/man/figures/progress-step-msg.svg index 299e3b65c..66449e2f7 100644 --- a/man/figures/progress-step-msg.svg +++ b/man/figures/progress-step-msg.svg @@ -1 +1 @@ -Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloaded819.20kB.[3.5s]Downloadingdata.Downloadingdata. \ No newline at end of file +Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloadingdata.Downloaded819.20kB.[3.5s]Downloadingdata.Downloadingdata. \ No newline at end of file diff --git a/man/figures/progress-step-spin.svg b/man/figures/progress-step-spin.svg index 6125f4f09..019e2b2ca 100644 --- a/man/figures/progress-step-spin.svg +++ b/man/figures/progress-step-spin.svg @@ -1 +1 @@ -DownloadingdataDownloadingdataDownloadingdataDownloadingdata[2.4s]Importingdata[1s]Cleaningdata[2s]FittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodel[3.5s]DownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataImportingdataCleaningdataFittingmodelFittingmodel \ No newline at end of file +DownloadingdataDownloadingdataDownloadingdataDownloadingdata[2.5s]Importingdata[1s]Cleaningdata[2s]FittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodelFittingmodel[3.4s]DownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataDownloadingdataImportingdataCleaningdataFittingmodelFittingmodel \ No newline at end of file diff --git a/man/figures/progress-step.svg b/man/figures/progress-step.svg index 6b2f4046c..77bcce08c 100644 --- a/man/figures/progress-step.svg +++ b/man/figures/progress-step.svg @@ -1 +1 @@ -Downloadingdata[2s]Importingdata[1s]Cleaningdata[2s]Fittingmodel[3s]DownloadingdataImportingdataCleaningdataFittingmodel \ No newline at end of file +Downloadingdata[2s]Importingdata[1s]Cleaningdata[2s]Fittingmodel[3s]DownloadingdataImportingdataCleaningdataFittingmodel \ No newline at end of file diff --git a/man/figures/progress-tasks.svg b/man/figures/progress-tasks.svg index baa911a5f..0afb100fa 100644 --- a/man/figures/progress-tasks.svg +++ b/man/figures/progress-tasks.svg @@ -1 +1 @@ -3/3ETA:0s|Tasks1/3ETA:2s|Tasks2/3ETA:1s|Tasks \ No newline at end of file +3/3ETA:0s|Tasks1/3ETA:2s|Tasks2/3ETA:1s|Tasks \ No newline at end of file From c92376407909a0884c62df061fc140fe5f9e0780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 22 Mar 2023 14:45:32 +0100 Subject: [PATCH 41/67] Fix snapshots --- tests/testthat/_snaps/1.0.6/rlang-errors.md | 10 ---- .../_snaps/rlang-1.1.0/rlang-errors.md | 54 +++++++++++++++++++ tests/testthat/_snaps/rlang-errors.md | 30 ----------- tests/testthat/test-rlang-errors.R | 8 +-- 4 files changed, 59 insertions(+), 43 deletions(-) delete mode 100644 tests/testthat/_snaps/1.0.6/rlang-errors.md create mode 100644 tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md diff --git a/tests/testthat/_snaps/1.0.6/rlang-errors.md b/tests/testthat/_snaps/1.0.6/rlang-errors.md deleted file mode 100644 index 801363b89..000000000 --- a/tests/testthat/_snaps/1.0.6/rlang-errors.md +++ /dev/null @@ -1,10 +0,0 @@ -# cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386) - - Code - (expect_error(fn())) - Output - - Error in `fn()`: - ! Message. - i This is an internal error that was detected in the base package. - diff --git a/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md b/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md new file mode 100644 index 000000000..5251a8637 --- /dev/null +++ b/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md @@ -0,0 +1,54 @@ +# cli_abort() captures correct call and backtrace + + Code + print(expect_error(f())) + Output + + Error in `h()`: + ! foo + --- + Backtrace: + x + 1. +-base::print(expect_error(f())) + 2. +-testthat::expect_error(f()) + 3. | \-testthat:::expect_condition_matching(...) + 4. | \-testthat:::quasi_capture(...) + 5. | +-testthat (local) .capture(...) + 6. | | \-base::withCallingHandlers(...) + 7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) + 8. \-cli (local) f() + 9. \-cli (local) g() + 10. \-cli (local) h() + +--- + + Code + print(expect_error(f(list()))) + Output + + Error in `h()`: + ! `x` can't be empty. + --- + Backtrace: + x + 1. +-base::print(expect_error(f(list()))) + 2. +-testthat::expect_error(f(list())) + 3. | \-testthat:::expect_condition_matching(...) + 4. | \-testthat:::quasi_capture(...) + 5. | +-testthat (local) .capture(...) + 6. | | \-base::withCallingHandlers(...) + 7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) + 8. \-cli (local) f(list()) + 9. \-cli (local) g(x) + 10. \-cli (local) h(x) + +# cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386) + + Code + (expect_error(fn())) + Output + + Error in `fn()`: + ! Message. + i This is an internal error that was detected in the base package. + diff --git a/tests/testthat/_snaps/rlang-errors.md b/tests/testthat/_snaps/rlang-errors.md index ab4b368db..30e40e77e 100644 --- a/tests/testthat/_snaps/rlang-errors.md +++ b/tests/testthat/_snaps/rlang-errors.md @@ -369,33 +369,3 @@ Output color me interested -# cli_abort() captures correct call and backtrace - - Code - print(expect_error(f())) - Output - - Error in `h()`: - ! foo - --- - Backtrace: - 1. base::print(expect_error(f())) - 8. cli (local) f() - 9. cli (local) g() - 10. cli (local) h() - ---- - - Code - print(expect_error(f(list()))) - Output - - Error in `h()`: - ! `x` can't be empty. - --- - Backtrace: - 1. base::print(expect_error(f(list()))) - 8. cli (local) f(list()) - 9. cli (local) g(x) - 10. cli (local) h(x) - diff --git a/tests/testthat/test-rlang-errors.R b/tests/testthat/test-rlang-errors.R index 80686a002..d92c436ef 100644 --- a/tests/testthat/test-rlang-errors.R +++ b/tests/testthat/test-rlang-errors.R @@ -133,6 +133,7 @@ test_that_cli(config = "ansi", "update_rstudio_color", { }) test_that("cli_abort() captures correct call and backtrace", { + skip_on_cran() rlang::local_options( rlang_trace_top_env = environment(), rlang_trace_format_srcrefs = FALSE @@ -144,7 +145,7 @@ test_that("cli_abort() captures correct call and backtrace", { expect_snapshot({ print(expect_error(f())) - }) + }, variant = paste0("rlang-", packageVersion("rlang"))) classed_stop <- function(message, env = parent.frame()) { cli::cli_abort( @@ -164,10 +165,11 @@ test_that("cli_abort() captures correct call and backtrace", { expect_snapshot({ print(expect_error(f(list()))) - }) + }, variant = paste0("rlang-", packageVersion("rlang"))) }) test_that("cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386)", { + skip_on_cran() fn <- function() { cli::cli_abort("Message.", .internal = TRUE) } @@ -176,5 +178,5 @@ test_that("cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang # Should mention an internal error in the `base` package expect_snapshot({ (expect_error(fn())) - }, variant = as.character(packageVersion("rlang"))) + }, variant = paste0("rlang-", packageVersion("rlang"))) }) From 2f57dc1a7d1f9f4bca86751d424f46f16387085a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 22 Mar 2023 14:58:57 +0100 Subject: [PATCH 42/67] Increment version number to 3.6.1 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 993d6ea3d..bd4d68b4d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.6.0.9000 +Version: 3.6.1 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 5e4f855d0..95a433c61 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cli (development version) +# cli 3.6.1 * ANSI hyperlinks are now turned off on the RStudio render plane (#581). From 1b60151331e7dc1cd96133ebcd9030307d93554f Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Wed, 22 Mar 2023 16:04:34 -0700 Subject: [PATCH 43/67] 'lengths' instead of 'length' --- R/diff.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/diff.R b/R/diff.R index a7bb48a14..7a74cfa31 100644 --- a/R/diff.R +++ b/R/diff.R @@ -167,7 +167,7 @@ get_diff_chunks <- function(lcs, context = 3L) { # chunk starts at operation number sum(length) before it, plus 1, but # at the end we change this to include the context chunks are well - chunks$op_begin <- c(0, cumsum(runs$length))[which(runs$values)] + 1 + chunks$op_begin <- c(0, cumsum(runs$lengths))[which(runs$values)] + 1 chunks$op_length <- runs$lengths[runs$values] # `old` positions are from `old_off`, but need to fix the boundaries From b4f0cefb12c8597f29f229bf89e9c41d4630a986 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Fri, 24 Mar 2023 10:33:53 -0400 Subject: [PATCH 44/67] Document `str` in the class list --- R/cliapp-docs.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index f55fc8777..c5b6aead4 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -80,6 +80,7 @@ #' * `run` is an R expression, that is potentially clickable if the terminal #' supports ANSI hyperlinks to runnable code (e.g. RStudio). #' It supports link text. See [links] for more about cli hyperlinks. +#' * `str` for a double quoted string. #' * `strong` for strong importance. #' * `topic` is a help page of a _ropic_. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), From df9517a07474a505ea85072d84c307397cbf27d5 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Fri, 24 Mar 2023 11:53:50 -0400 Subject: [PATCH 45/67] Mention `encodeString()` --- R/cliapp-docs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index c5b6aead4..c20ba5fa8 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -80,7 +80,7 @@ #' * `run` is an R expression, that is potentially clickable if the terminal #' supports ANSI hyperlinks to runnable code (e.g. RStudio). #' It supports link text. See [links] for more about cli hyperlinks. -#' * `str` for a double quoted string. +#' * `str` for a double quoted string escaped by [base::encodeString()]. #' * `strong` for strong importance. #' * `topic` is a help page of a _ropic_. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), From e1d9728a00e2bd5457f29848e8827ff0eb573842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sun, 26 Mar 2023 22:13:44 +0200 Subject: [PATCH 46/67] Increment version number to 3.6.1.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index bd4d68b4d..478e6c568 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cli Title: Helpers for Developing Command Line Interfaces -Version: 3.6.1 +Version: 3.6.1.9000 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")), person("Hadley", "Wickham", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 95a433c61..8a4fb9535 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# cli (development version) + # cli 3.6.1 * ANSI hyperlinks are now turned off on the RStudio render plane (#581). From c37f34be35d30e776d768509a38f1e5f710aab0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 7 Apr 2023 11:39:45 +0200 Subject: [PATCH 47/67] Fix pkgdown build on CI --- .github/workflows/pkgdown.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 2f6189fce..030dab9c2 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -19,6 +19,7 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_CLI_NUM_COLORS: 256 steps: - uses: actions/checkout@v3 @@ -37,8 +38,12 @@ jobs: needs: website - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + run: | + rmarkdown::render("README.Rmd") + pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} + env: + IN_PKGDOWN: true - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' From 6316614003eee466cd172737090f93749954e778 Mon Sep 17 00:00:00 2001 From: James Baird Date: Fri, 12 May 2023 13:17:07 +0100 Subject: [PATCH 48/67] Fix typo in "directory" --- R/cliapp-docs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index c20ba5fa8..99df4d093 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -203,7 +203,7 @@ #' ```{asciicast inline-plural} #' ndirs <- 1 #' nfiles <- 13 -#' cli_alert_info("Found {ndirs} diretor{?y/ies} and {nfiles} file{?s}.") +#' cli_alert_info("Found {ndirs} director{?y/ies} and {nfiles} file{?s}.") #' cli_text("Will install {length(pkgs)} package{?s}: {.pkg {pkgs}}") #' ``` #' From 94906ffbc28f2564f054ea60f3eeb72702fda638 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Mon, 15 May 2023 09:35:02 -0400 Subject: [PATCH 49/67] Tyoi --- R/cliapp-docs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 99df4d093..8dd14ea40 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -82,7 +82,7 @@ #' It supports link text. See [links] for more about cli hyperlinks. #' * `str` for a double quoted string escaped by [base::encodeString()]. #' * `strong` for strong importance. -#' * `topic` is a help page of a _ropic_. +#' * `topic` is a help page of a _topic_. #' If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), #' then cli creates a clickable link. It supports link text. #' See [links] for more about cli hyperlinks. From 288862e953ba741921a85b1af9df0b89d511f3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 25 May 2023 13:34:17 +0200 Subject: [PATCH 50/67] Add R-hub v2 workflow file [ci skip] --- .github/workflows/rhub.yaml | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/rhub.yaml diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 000000000..fe5a1822d --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,72 @@ +# R-hub's genetic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/rhub2/blob/v1/inst/workflow/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub2::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/rhub2/actions/rhub-setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: actions/checkout@v3 + - uses: r-hub/rhub2/actions/rhub-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: actions/checkout@v3 + - uses: r-hub/rhub2/actions/rhub-setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/rhub2/actions/rhub-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} From 97115643525cc76abea26456491df3db25e387fc Mon Sep 17 00:00:00 2001 From: Shian Su Date: Fri, 2 Jun 2023 15:40:10 +1000 Subject: [PATCH 51/67] Fixed typo --- R/progress-client.R | 2 +- man/cli_progress_step.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/progress-client.R b/R/progress-client.R index 549250968..b153b5f24 100644 --- a/R/progress-client.R +++ b/R/progress-client.R @@ -673,7 +673,7 @@ cli_progress_message <- function(msg, #' ## Spinner #' #' You can add a spinner to some or all steps with `spinner = TRUE`, -#' but not that this will only work if you call [cli_progress_update()] +#' but note that this will only work if you call [cli_progress_update()] #' regularly. #' #' ```{asciicast progress-step-spin} diff --git a/man/cli_progress_step.Rd b/man/cli_progress_step.Rd index 8e69d39be..37ef67943 100644 --- a/man/cli_progress_step.Rd +++ b/man/cli_progress_step.Rd @@ -72,7 +72,7 @@ f() \subsection{Spinner}{ You can add a spinner to some or all steps with \code{spinner = TRUE}, -but not that this will only work if you call \code{\link[=cli_progress_update]{cli_progress_update()}} +but note that this will only work if you call \code{\link[=cli_progress_update]{cli_progress_update()}} regularly. \if{html}{\out{
}}\preformatted{f <- function() \{ From b0752db2f72ceced0319d9b7077fe0b5188a1f9a Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Wed, 14 Jun 2023 17:48:55 -0700 Subject: [PATCH 52/67] Fix minor typo in hash_raw_animal docs --- R/hash.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/hash.R b/R/hash.R index a8c43f7fe..e8b588a01 100644 --- a/R/hash.R +++ b/R/hash.R @@ -468,7 +468,7 @@ hash_animal1_transform <- function(md5, n_adj) { #' @export #' @rdname hash_animal -#' @details `hash_raw_anima()` calculates the adjective-animal hash of +#' @details `hash_raw_animal()` calculates the adjective-animal hash of #' the bytes of a raw vector. #' #' @return `hash_raw_animal()` and `hash_obj_animal()` return a list From 74fd22a8de0cebb1ecd2cd7fd2ed005f7de940ce Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Thu, 15 Jun 2023 07:53:01 -0700 Subject: [PATCH 53/67] Fixed typo in hash_animal() docs --- R/hash.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/hash.R b/R/hash.R index e8b588a01..372e4c31b 100644 --- a/R/hash.R +++ b/R/hash.R @@ -378,7 +378,7 @@ hash_obj_emoji <- function(x, size = 3, serialize_version = 2) { #' } #' ``` #' -#' `hash_animals()` uses `r length(gfycat_animals)` animal names and +#' `hash_animal()` uses `r length(gfycat_animals)` animal names and #' `r length(gfycat_adjectives)` different adjectives. The number of #' different hashes you can get for different values of `n_adj`: #' From 2a896ace1beeb2ed1d37e9a52a019e85a50dca13 Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Thu, 15 Jun 2023 08:01:20 -0700 Subject: [PATCH 54/67] Update hash.R Fixed typo in hash_sha1() docs --- R/hash.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/hash.R b/R/hash.R index 372e4c31b..e5737d878 100644 --- a/R/hash.R +++ b/R/hash.R @@ -76,7 +76,7 @@ hash_file_sha256 <- function(paths) { #' @param x Character vector. If not a character vector, then #' [as.character()] is used to try to coerce it into one. `NA` entries #' will have an `NA` hash. -#' @return `hash_sha1()` returns aharacter vector of hexadecimal +#' @return `hash_sha1()` returns a character vector of hexadecimal #' SHA-1 hashes. #' @family hash functions From 17c3bc3fead640183460913663d0974343454432 Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Thu, 15 Jun 2023 08:04:53 -0700 Subject: [PATCH 55/67] Fixed a few typos in hash_md5() docs --- R/hash.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/hash.R b/R/hash.R index e5737d878..43c9b64de 100644 --- a/R/hash.R +++ b/R/hash.R @@ -194,7 +194,7 @@ hash_obj_md5 <- function(x, serialize_version = 2) { #' @export #' @rdname hash_md5 #' @param paths Character vector of file names. -#' @details `hash_file_md5()` calcultaes the MD5 hash of one of more +#' @details `hash_file_md5()` calculates the MD5 hash of one or more #' files. hash_file_md5 <- function(paths) { From dc095a3ba035f7595828076b8215e16e78101875 Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Thu, 15 Jun 2023 08:13:02 -0700 Subject: [PATCH 56/67] Replaced between to remove ambiguitity about whether range is inclusive --- R/hash.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/hash.R b/R/hash.R index 43c9b64de..601a86c4b 100644 --- a/R/hash.R +++ b/R/hash.R @@ -236,7 +236,7 @@ hash_file_md5 <- function(paths) { #' #' @param x Character vector. `NA` entries will have an `NA` hash. #' @param size Number of emojis to use in a hash. Currently it has to -#' be between 1 and 4. +#' be from 1 through 4. #' @return `hash_emoji()` returns a data frame with columns #' * `hash`: the emoji hash, a string of the requested size. #' * `emojis`: list column with the emoji characters in character @@ -397,7 +397,7 @@ hash_obj_emoji <- function(x, size = 3, serialize_version = 2) { #' from . #' #' @param x Character vector. `NA` entries will have an `NA` hash. -#' @param n_adj Number of adjectives to use. It must be between 0 and 3. +#' @param n_adj Number of adjectives to use. It must be from 0 through 3. #' @return A data frame with columns #' * `hash`: the hash value, a string. #' * `words`: list column with the adjectives and the animal name in a From 7b3d42ae02fbc461feeff7361c939ff7282232be Mon Sep 17 00:00:00 2001 From: Justin Mills Date: Thu, 15 Jun 2023 11:21:17 -0700 Subject: [PATCH 57/67] Update hash.R Fixed minor typo in hash_sha256() docs --- R/hash.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/hash.R b/R/hash.R index 601a86c4b..e5b77589e 100644 --- a/R/hash.R +++ b/R/hash.R @@ -6,7 +6,7 @@ #' @param x Character vector. If not a character vector, then #' [as.character()] is used to try to coerce it into one. `NA` entries #' will have an `NA` hash. -#' @return `hash_sha256()` returns aharacter vector of hexadecimal +#' @return `hash_sha256()` returns a character vector of hexadecimal #' SHA-256 hashes. #' @family hash functions From 723310cbeca6a25dc5a3ae74ade52938668ecc31 Mon Sep 17 00:00:00 2001 From: we Date: Sat, 22 Jul 2023 13:16:56 +0800 Subject: [PATCH 58/67] Add missing c() in cli_abort() --- vignettes/usethis-ui.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vignettes/usethis-ui.Rmd b/vignettes/usethis-ui.Rmd index 9401f60d9..97aca7dcc 100644 --- a/vignettes/usethis-ui.Rmd +++ b/vignettes/usethis-ui.Rmd @@ -291,10 +291,10 @@ ui_stop("Could not copy {ui_path(img)} to {ui_path(logo_path)}, file already ex `cli_abort()` does the same and is formatted using `cli_bullets()`. ```{asciicast} -cli_abort( +cli_abort(c( "Could not copy {.file {img}} to {.file {logo_path}}, file already exists", "i" = "You can set {.arg overwrite = TRUE} to avoid this error" - ) + )) ``` ## `usethis::ui_todo()` @@ -360,10 +360,10 @@ ui_warn("Could not copy {ui_path(img)} to {ui_path(logo_path)}, file already ex `cli_warn()` does the same and is formatted using `cli_bullets()`. ```{asciicast} -cli_warn( +cli_warn(c( "Could not copy {.file {img}} to {.file {logo_path}}, file already exists", "i" = "You can set {.arg overwrite = TRUE} to avoid this warning" - ) + )) ``` ## `usethis::ui_yeah()` From 3b43a3a0828ff76908fda07ad1c506666e57f933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 25 Jul 2023 11:01:05 +0200 Subject: [PATCH 59/67] Move scripts to /exec --- {inst/scripts => exec}/news.R | 0 {inst/scripts => exec}/outdated.R | 0 {inst/scripts => exec}/search.R | 0 {inst/scripts => exec}/up.R | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {inst/scripts => exec}/news.R (100%) rename {inst/scripts => exec}/outdated.R (100%) rename {inst/scripts => exec}/search.R (100%) rename {inst/scripts => exec}/up.R (100%) diff --git a/inst/scripts/news.R b/exec/news.R similarity index 100% rename from inst/scripts/news.R rename to exec/news.R diff --git a/inst/scripts/outdated.R b/exec/outdated.R similarity index 100% rename from inst/scripts/outdated.R rename to exec/outdated.R diff --git a/inst/scripts/search.R b/exec/search.R similarity index 100% rename from inst/scripts/search.R rename to exec/search.R diff --git a/inst/scripts/up.R b/exec/up.R similarity index 100% rename from inst/scripts/up.R rename to exec/up.R From 525ebbebd399d331dfcb43bb28d09bc62f13b711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Tue, 25 Jul 2023 15:24:25 +0200 Subject: [PATCH 60/67] Fix URLs in news.R script --- exec/news.R | 3 ++- inst/examples/apps/news.R | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/exec/news.R b/exec/news.R index ec219ce8e..99c155734 100755 --- a/exec/news.R +++ b/exec/news.R @@ -107,11 +107,12 @@ New package releases on CRAN format_result <- function(result) { pkg <- result$package ago <- vague_dt(Sys.time() - parse_iso_8601(result$date)) + url <- paste0("https://r-pkg.org/pkg/", pkg$Package) cli_li() cli_text("{.pkg {pkg$Package}} {pkg$Version} -- {ago} by {.emph {pkg$Maintainer}}") cli_text("{pkg$Title}") - cli_text("{.url https://r-pkg.org/pkg/{pkg$Package}}") + cli_text("{.url {url}}") } if (is.null(sys.calls())) { diff --git a/inst/examples/apps/news.R b/inst/examples/apps/news.R index ec219ce8e..99c155734 100755 --- a/inst/examples/apps/news.R +++ b/inst/examples/apps/news.R @@ -107,11 +107,12 @@ New package releases on CRAN format_result <- function(result) { pkg <- result$package ago <- vague_dt(Sys.time() - parse_iso_8601(result$date)) + url <- paste0("https://r-pkg.org/pkg/", pkg$Package) cli_li() cli_text("{.pkg {pkg$Package}} {pkg$Version} -- {ago} by {.emph {pkg$Maintainer}}") cli_text("{pkg$Title}") - cli_text("{.url https://r-pkg.org/pkg/{pkg$Package}}") + cli_text("{.url {url}}") } if (is.null(sys.calls())) { From 88cc28024b3ca5754a08983b0a226f259135b6a6 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 29 Jul 2023 20:35:08 +0200 Subject: [PATCH 61/67] Fix typo --- R/glue.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/glue.R b/R/glue.R index 753c38e75..d9ceb9f3b 100644 --- a/R/glue.R +++ b/R/glue.R @@ -85,7 +85,7 @@ drop_null <- function(x) { #' @param width Limit for the display width of the result, in characters. #' This is a hard limit, and the output will never exceed it. #' This argument is not implemented for the `"both-ends"` style, which -#' always uses `Inf`, with a warning if a fininte `width` value is set. +#' always uses `Inf`, with a warning if a finite `width` value is set. #' @param ellipsis Character string to use at the place of the truncation. #' By default, the Unicode ellipsis character is used if the console is #' UTF-8, and three dots otherwise. From 744bc272f95f22700aee845137d241d68ad01c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 18 Aug 2023 13:33:28 +0200 Subject: [PATCH 62/67] Redocument --- DESCRIPTION | 2 +- R/cliapp-docs.R | 1 + man/ansi_collapse.Rd | 2 +- man/hash_animal.Rd | 6 +++--- man/hash_emoji.Rd | 2 +- man/hash_md5.Rd | 2 +- man/hash_sha1.Rd | 2 +- man/hash_sha256.Rd | 2 +- man/inline-markup.Rd | 27 ++++++++++++++------------- 9 files changed, 24 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 478e6c568..e1fdfc515 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -57,4 +57,4 @@ Config/Needs/website: vctrs Config/testthat/edition: 3 Encoding: UTF-8 -RoxygenNote: 7.2.1.9000 +RoxygenNote: 7.2.3 diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 0a1100658..0bfc775c8 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -202,6 +202,7 @@ #' ```{asciicast inline-plural} #' ndirs <- 1 #' nfiles <- 13 +#' pkgs <- c("pkg1", "pkg2", "pkg3") #' cli_alert_info("Found {ndirs} director{?y/ies} and {nfiles} file{?s}.") #' cli_text("Will install {length(pkgs)} package{?s}: {.pkg {pkgs}}") #' ``` diff --git a/man/ansi_collapse.Rd b/man/ansi_collapse.Rd index b4dd3a457..062ea3d50 100644 --- a/man/ansi_collapse.Rd +++ b/man/ansi_collapse.Rd @@ -30,7 +30,7 @@ at least \code{trunc = 1} is used. For \code{style = "both-ends"} at least \item{width}{Limit for the display width of the result, in characters. This is a hard limit, and the output will never exceed it. This argument is not implemented for the \code{"both-ends"} style, which -always uses \code{Inf}, with a warning if a fininte \code{width} value is set.} +always uses \code{Inf}, with a warning if a finite \code{width} value is set.} \item{ellipsis}{Character string to use at the place of the truncation. By default, the Unicode ellipsis character is used if the console is diff --git a/man/hash_animal.Rd b/man/hash_animal.Rd index 81f2fb7ea..de61abd3a 100644 --- a/man/hash_animal.Rd +++ b/man/hash_animal.Rd @@ -15,7 +15,7 @@ hash_obj_animal(x, n_adj = 2, serialize_version = 2) \arguments{ \item{x}{Character vector. \code{NA} entries will have an \code{NA} hash.} -\item{n_adj}{Number of adjectives to use. It must be between 0 and 3.} +\item{n_adj}{Number of adjectives to use. It must be from 0 through 3.} \item{serialize_version}{Workspace format version to use, see \code{\link[base:serialize]{base::serialize()}}.} @@ -44,7 +44,7 @@ hash of the input, and converts them into an adjective-animal form to create a human readable hash. \subsection{Number of possible hash values}{ -\code{hash_animals()} uses 1748 animal names and +\code{hash_animal()} uses 1748 animal names and 8946 different adjectives. The number of different hashes you can get for different values of \code{n_adj}:\tabular{rr}{ \code{n_adj} \tab size of the hash table space \cr @@ -64,7 +64,7 @@ and in turn from from \url{https://gfycat.com}. } -\code{hash_raw_anima()} calculates the adjective-animal hash of +\code{hash_raw_animal()} calculates the adjective-animal hash of the bytes of a raw vector. \code{hash_obj_animal()} calculates the adjective-animal hash of diff --git a/man/hash_emoji.Rd b/man/hash_emoji.Rd index c1494e0e3..86b6b073f 100644 --- a/man/hash_emoji.Rd +++ b/man/hash_emoji.Rd @@ -16,7 +16,7 @@ hash_obj_emoji(x, size = 3, serialize_version = 2) \item{x}{Character vector. \code{NA} entries will have an \code{NA} hash.} \item{size}{Number of emojis to use in a hash. Currently it has to -be between 1 and 4.} +be from 1 through 4.} \item{serialize_version}{Workspace format version to use, see \code{\link[base:serialize]{base::serialize()}}.} diff --git a/man/hash_md5.Rd b/man/hash_md5.Rd index 686fe6ff7..5c766d3ac 100644 --- a/man/hash_md5.Rd +++ b/man/hash_md5.Rd @@ -43,7 +43,7 @@ of a raw vector. \code{hash_obj_md5()} calculates the MD5 hash of an R object. The object is serialized into a binary vector first. -\code{hash_file_md5()} calcultaes the MD5 hash of one of more +\code{hash_file_md5()} calculates the MD5 hash of one or more files. } \examples{ diff --git a/man/hash_sha1.Rd b/man/hash_sha1.Rd index 405aff071..cda5b6183 100644 --- a/man/hash_sha1.Rd +++ b/man/hash_sha1.Rd @@ -26,7 +26,7 @@ will have an \code{NA} hash.} \item{paths}{Character vector of file names.} } \value{ -\code{hash_sha1()} returns aharacter vector of hexadecimal +\code{hash_sha1()} returns a character vector of hexadecimal SHA-1 hashes. \code{hash_raw_sha1()} returns a character scalar. diff --git a/man/hash_sha256.Rd b/man/hash_sha256.Rd index d90d569a2..959781770 100644 --- a/man/hash_sha256.Rd +++ b/man/hash_sha256.Rd @@ -26,7 +26,7 @@ will have an \code{NA} hash.} \item{paths}{Character vector of file names.} } \value{ -\code{hash_sha256()} returns aharacter vector of hexadecimal +\code{hash_sha256()} returns a character vector of hexadecimal SHA-256 hashes. \code{hash_raw_sha256()} returns a character scalar. diff --git a/man/inline-markup.Rd b/man/inline-markup.Rd index b2c1e5d07..d328e3573 100644 --- a/man/inline-markup.Rd +++ b/man/inline-markup.Rd @@ -67,26 +67,26 @@ The default theme defines the following inline classes: \item \code{email} for an email address. If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{emph} for emphasized text. \item \code{envvar} for the name of an environment variable. \item \code{field} for a generic field, e.g. in a named list. \item \code{file} for a file name. If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link that opens the file in RStudio or with the default app for the file type. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{fun} for a function name. If it is in the \code{package::function_name} form, and the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{help} is a help page of a \emph{function}. If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{href} creates a hyperlink, potentially with a link text. If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{key} for a keyboard key. \item \code{obj_type_friendly} formats the type of an R object in a readable way, and it should be used with \code{{}}, see an example below. @@ -96,23 +96,23 @@ collapsed vectors (see below) from "and" to "or". \item \code{pkg} for a package name. \item \code{run} is an R expression, that is potentially clickable if the terminal supports ANSI hyperlinks to runnable code (e.g. RStudio). -It supports link text. See \link{links} for more about cli hyperlinks. -\item \code{strong} for strong importance. -\item \code{topic} is a help page of a \emph{ropic}. +It supports link text. See \link{links} for more information about cli hyperlinks. +\item \code{str} for a double quoted string escaped by \code{\link[base:encodeString]{base::encodeString()}}.#' * \code{strong} for strong importance. +\item \code{topic} is a help page of a \emph{topic}. If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{type} formats the type of an R object in a readable way, and it should be used with \code{{}}, see an example below. \item \code{url} for a URL. If the terminal supports ANSI hyperlinks (e.g. RStudio, iTerm2, etc.), then cli creates a clickable link. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. \item \code{var} for a variable name. \item \code{val} for a generic "value". \item \code{vignette} is a vignette. If the terminal supports ANSI hyperlinks to help pages (e.g. RStudio), then cli creates a clickable link. It supports link text. -See \link{links} for more about cli hyperlinks. +See \link{links} for more information about cli hyperlinks. } \if{html}{\out{
}}\preformatted{ul <- cli_ul() @@ -267,11 +267,12 @@ All cli commands that emit text support pluralization. Some examples: \if{html}{\out{
}}\preformatted{ndirs <- 1 nfiles <- 13 -cli_alert_info("Found \{ndirs\} diretor\{?y/ies\} and \{nfiles\} file\{?s\}.") +pkgs <- c("pkg1", "pkg2", "pkg3") +cli_alert_info("Found \{ndirs\} director\{?y/ies\} and \{nfiles\} file\{?s\}.") cli_text("Will install \{length(pkgs)\} package\{?s\}: \{.pkg \{pkgs\}\}") }\if{html}{\out{
}}\if{html}{\out{
-#>  Found 1 diretory and 13 files.                                                
+#>  Found 1 directory and 13 files.                                               
 #> Will install 3 packages: pkg1, pkg2, and pkg3                                   
 
}} From cb09f2ad39493efb9f026680d4e2e1c9d654bd05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 18 Aug 2023 13:34:41 +0200 Subject: [PATCH 63/67] Change semantics of cli.default_num_colors option So that it is possible to use it even if color support is not detected, but at least it is not ruled out by some other options and detections. --- R/num-ansi-colors.R | 5 +++++ vignettes/cli-config-user.Rmd | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/R/num-ansi-colors.R b/R/num-ansi-colors.R index 93715917c..c23cffa5f 100644 --- a/R/num-ansi-colors.R +++ b/R/num-ansi-colors.R @@ -106,6 +106,11 @@ num_ansi_colors <- function(stream = "auto") { # the `stderr()` stream, so we need to catch this case. if (is_stderr && sink.number("message") != 2) return(1L) + #' 1. If the `cli.default_num_colors` option is set, then we use that. + + dopt <- get_default_number_of_colors() + if (!is.null(dopt)) return(as.integer(dopt)) + #' 1. If R is running inside RGui on Windows, or R.app on macOS, then we #' return 1L. diff --git a/vignettes/cli-config-user.Rmd b/vignettes/cli-config-user.Rmd index 1a1e34d0a..51dcf2943 100644 --- a/vignettes/cli-config-user.Rmd +++ b/vignettes/cli-config-user.Rmd @@ -79,9 +79,21 @@ See ### `cli.default_num_colors` -Default number of ANSI colors. This value is only used if ANSI color support -is detected. You can set this value to keep relying on auto-detection, -but to adjust the number of colors when cli detects color support. +Default number of ANSI colors. This value is used if the number of colors +is not already set by +* the `cli.num_colors` option, +* the `R_CLI_NU<_COLORS` environment variable, +* the `crayon.enabled` and `crayon.colors` options, +* the `NO_COLOR` environment variable, +* the `knitr.in.progress` option, +* a `sink()` call for the stream. + +You can also use this option if color support is detected correctly, but +you want to adjust the number of colors. E.g. +* if `crayon.enabled` is `TRUE`, but `crayon.colors` is not, +* in Emacs on Windows, +* in terminals. + See [num_ansi_colors()]. See also the `cli.num_colors` option. ### `cli.dynamic` From 6d458bba1c9c5fbeb7a0c48f2ebfcb84b12de83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 18 Aug 2023 13:47:54 +0200 Subject: [PATCH 64/67] Document [ci skip] --- man/cli-config.Rd | 22 +++++++++++++++++++--- man/num_ansi_colors.Rd | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/man/cli-config.Rd b/man/cli-config.Rd index 46d92866e..d6094ca31 100644 --- a/man/cli-config.Rd +++ b/man/cli-config.Rd @@ -88,9 +88,25 @@ See \url{https://cli.r-lib.org/articles/semantic-cli.html#cli-messages-1} \subsection{\code{cli.default_num_colors}}{ -Default number of ANSI colors. This value is only used if ANSI color support -is detected. You can set this value to keep relying on auto-detection, -but to adjust the number of colors when cli detects color support. +Default number of ANSI colors. This value is used if the number of colors +is not already set by +\itemize{ +\item the \code{cli.num_colors} option, +\item the \verb{R_CLI_NU<_COLORS} environment variable, +\item the \code{crayon.enabled} and \code{crayon.colors} options, +\item the \code{NO_COLOR} environment variable, +\item the \code{knitr.in.progress} option, +\item a \code{sink()} call for the stream. +} + +You can also use this option if color support is detected correctly, but +you want to adjust the number of colors. E.g. +\itemize{ +\item if \code{crayon.enabled} is \code{TRUE}, but \code{crayon.colors} is not, +\item in Emacs on Windows, +\item in terminals. +} + See \code{\link[=num_ansi_colors]{num_ansi_colors()}}. See also the \code{cli.num_colors} option. } diff --git a/man/num_ansi_colors.Rd b/man/num_ansi_colors.Rd index 5bb3d044c..90f3e4936 100644 --- a/man/num_ansi_colors.Rd +++ b/man/num_ansi_colors.Rd @@ -62,6 +62,7 @@ be actually used, but there is no easy way to tell that.) active sink for it, then 1L is returned. (If a sink is active for "output", then R changes the \code{stdout()} stream, so this check is not needed.) +\item If the \code{cli.default_num_colors} option is set, then we use that. \item If R is running inside RGui on Windows, or R.app on macOS, then we return 1L. \item If R is running inside RStudio, with color support, then the From c36066ca6a208edbeb37ab13467a4dc6f5b5bbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 18 Aug 2023 15:18:33 +0200 Subject: [PATCH 65/67] Docs typo [ci skip] --- man/cli-config.Rd | 2 +- vignettes/cli-config-user.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/cli-config.Rd b/man/cli-config.Rd index d6094ca31..41f8205d8 100644 --- a/man/cli-config.Rd +++ b/man/cli-config.Rd @@ -92,7 +92,7 @@ Default number of ANSI colors. This value is used if the number of colors is not already set by \itemize{ \item the \code{cli.num_colors} option, -\item the \verb{R_CLI_NU<_COLORS} environment variable, +\item the \code{R_CLI_NUM_COLORS} environment variable, \item the \code{crayon.enabled} and \code{crayon.colors} options, \item the \code{NO_COLOR} environment variable, \item the \code{knitr.in.progress} option, diff --git a/vignettes/cli-config-user.Rmd b/vignettes/cli-config-user.Rmd index 51dcf2943..6dfe66c3d 100644 --- a/vignettes/cli-config-user.Rmd +++ b/vignettes/cli-config-user.Rmd @@ -82,7 +82,7 @@ See Default number of ANSI colors. This value is used if the number of colors is not already set by * the `cli.num_colors` option, -* the `R_CLI_NU<_COLORS` environment variable, +* the `R_CLI_NUM_COLORS` environment variable, * the `crayon.enabled` and `crayon.colors` options, * the `NO_COLOR` environment variable, * the `knitr.in.progress` option, From d619ed4d5d0736d92f82406bc7354df6ea7b25d8 Mon Sep 17 00:00:00 2001 From: "Mathew W. McLean" Date: Thu, 24 Aug 2023 12:42:45 +1000 Subject: [PATCH 66/67] DS-5106: Rerun GitHub Action From 60957b225d6914b571857db1af1eb6e5b846ddd1 Mon Sep 17 00:00:00 2001 From: jrwishart Date: Wed, 25 Oct 2023 13:48:45 +1100 Subject: [PATCH 67/67] Trigger tests