Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@
^man/chunks/FAQ_cache$
^codecov\.yml$
^tests/testthat/results.rds$
^[\.]?air\.toml$
^\.vscode$
4 changes: 0 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check.yaml

Expand All @@ -24,11 +23,8 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'devel'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'next'}
- {os: windows-latest, r: 'release'}
# use 4.0 or 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: 'oldrel-4'}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage.yaml

Expand Down Expand Up @@ -35,14 +34,16 @@ jobs:
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
}
}
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Authors@R: c(
person("Kirill", "Müller", role = "ctb"),
person("Salim", "Brüggemann", , "salim-b@pm.me", role = "ctb",
comment = c(ORCID = "0000-0002-5329-5987")),
person("Posit Software, PBC", role = c("cph", "fnd"))
person("Posit Software, PBC", role = c("cph", "fnd"),
comment = c(ROR = "03wc8by49"))
)
Description: A suite of tools to build attractive command line interfaces
('CLIs'), from semantic elements: headings, lists, alerts, paragraphs,
Expand Down Expand Up @@ -57,5 +58,6 @@ Config/Needs/website:
usethis,
vctrs
Config/testthat/edition: 3
Config/usethis/last-upkeep: 2025-04-25
Encoding: UTF-8
RoxygenNote: 7.3.2
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2023
YEAR: 2025
COPYRIGHT HOLDER: cli authors
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2023 cli authors
Copyright (c) 2025 cli authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 2 additions & 4 deletions R/aaa-utils.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

`%||%` <- function(l, r) if (is.null(l)) r else l

new_class <- function(class_name, ...) {
Expand Down Expand Up @@ -32,13 +31,12 @@ is_latex_output <- function() {
get("is_latex_output", asNamespace("knitr"))()
}

is_windows <- function() {
is_windows <- function() {
.Platform$OS.type == "windows"
}

apply_style <- function(text, style, bg = FALSE) {
if (identical(text, ""))
return(text)
if (identical(text, "")) return(text)

if (is.function(style)) {
style(text)
Expand Down
63 changes: 28 additions & 35 deletions R/aab-rstudio-detect.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

rstudio <- local({

standalone_env <- environment()
parent.env(standalone_env) <- baseenv()

Expand All @@ -18,7 +16,8 @@ rstudio <- local({
"RSTUDIO_CONSOLE_COLOR",
"RSTUDIOAPI_IPC_REQUESTS_FILE",
"XPC_SERVICE_NAME",
"ASCIICAST")
"ASCIICAST"
)

d <- list(
pid = Sys.getpid(),
Expand Down Expand Up @@ -60,8 +59,10 @@ rstudio <- local({
if (clear_cache) data <<- NULL
if (!is.null(data)) return(get_caps(data))

if ((rspid <- Sys.getenv("RSTUDIO_SESSION_PID")) != "" &&
any(c("ps", "cli") %in% loadedNamespaces())) {
if (
(rspid <- Sys.getenv("RSTUDIO_SESSION_PID")) != "" &&
any(c("ps", "cli") %in% loadedNamespaces())
) {
detect_new(rspid, clear_cache)
} else {
detect_old(clear_cache)
Expand Down Expand Up @@ -94,31 +95,26 @@ rstudio <- local({

# direct subprocess
new$type <- if (rspid == parentpid) {

if (pane == "job") {
"rstudio_job"

} else if (pane == "build") {
"rstudio_build_pane"

} else if (pane == "render") {
"rstudio_render_pane"

} else if (pane == "terminal" && new$tty &&
new$envs["ASCIICAST"] != "true") {
} else if (
pane == "terminal" && new$tty && new$envs["ASCIICAST"] != "true"
) {
# not possible, because there is a shell in between, just in case
"rstudio_terminal"

} else {
# don't know what kind of direct subprocess
"rstudio_subprocess"
}

} else if (pane == "terminal" && new$tty &&
new$envs[["ASCIICAST"]] != "true") {
} else if (
pane == "terminal" && new$tty && new$envs[["ASCIICAST"]] != "true"
) {
# not a direct subproces, so check other criteria as well
"rstudio_terminal"

} else {
# don't know what kind of subprocess
"rstudio_subprocess"
Expand All @@ -128,58 +124,55 @@ rstudio <- local({
}

detect_old <- function(clear_cache = FALSE) {

# Cache unless told otherwise
cache <- TRUE
new <- get_data()

new$type <- if (new$envs[["RSTUDIO"]] != "1") {
# 1. Not RStudio at all
"not_rstudio"

} else if (new$gui == "RStudio" && new$api) {
# 2. RStudio console, properly initialized
"rstudio_console"

} else if (! new$api && basename(new$args[1]) == "RStudio") {
} else if (!new$api && basename(new$args[1]) == "RStudio") {
# 3. RStudio console, initializing
cache <- FALSE
"rstudio_console_starting"

} else if (new$gui == "Rgui") {
# Still not RStudio, but Rgui that was started from RStudio
"not_rstudio"

} else if (new$tty && new$envs[["ASCIICAST"]] != "true") {
# 4. R in the RStudio terminal
# This could also be a subprocess of the console or build pane
# with a pseudo-terminal. There isn't really a way to rule that
# out, without inspecting some process data with ps::ps_*().
# At least we rule out asciicast
"rstudio_terminal"

} else if (! new$tty &&
new$envs[["RSTUDIO_TERM"]] == "" &&
new$envs[["R_BROWSER"]] == "false" &&
new$envs[["R_PDFVIEWER"]] == "false" &&
is_build_pane_command(new$args)) {
} else if (
!new$tty &&
new$envs[["RSTUDIO_TERM"]] == "" &&
new$envs[["R_BROWSER"]] == "false" &&
new$envs[["R_PDFVIEWER"]] == "false" &&
is_build_pane_command(new$args)
) {
# 5. R in the RStudio build pane
# https://github.com/rstudio/rstudio/blob/main/src/cpp/session/
# modules/build/SessionBuild.cpp#L231-L240
"rstudio_build_pane"

} else if (new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]], fixed = TRUE)) {
} else if (
new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]], fixed = TRUE)
) {
# RStudio job, XPC_SERVICE_NAME=0 in the subprocess of a job
# process. Hopefully this is reliable.
"rstudio_job"

} else if (new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
any(grepl("SourceWithProgress.R", new$args))) {
} else if (
new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
any(grepl("SourceWithProgress.R", new$args))
) {
# Or we can check SourceWithProgress.R in the command line, see
# https://github.com/r-lib/cli/issues/367
"rstudio_job"

} else {
# Otherwise it is a subprocess of the console, terminal or
# build pane, and it is hard to say which, so we do not try.
Expand Down
Loading