Skip to content

Commit 1cd9380

Browse files
committed
Not all function support --quiet in quarto CLI
So keep adding it in wrapper function instead, but handle the option overwrite in checking for the arg Revert f423a89
1 parent 1a2359f commit 1cd9380

File tree

14 files changed

+42
-37
lines changed

14 files changed

+42
-37
lines changed

R/add.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ quarto_add_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FA
4040
approval <- check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
4141

4242
if (approval) {
43-
args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)
43+
args <- c(extension, "--no-prompt", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args)
4444
quarto_add(args, quarto_bin = quarto_bin, echo = TRUE)
4545
}
4646

R/create.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt =
3939

4040
quarto_bin <- find_quarto()
4141

42-
args <- c("project", type, name, "--no-prompt", "--no-open", if (quiet) cli_arg_quiet(), quarto_args = NULL)
42+
args <- c("project", type, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL)
4343

4444
owd <- setwd(dir)
4545
on.exit(setwd(owd), add = TRUE, after = FALSE)

R/inspect.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ quarto_inspect <- function(input = ".",
4141
args <- c(args, c("--profile", paste0(profile, collapse = ",")))
4242
}
4343

44+
if (is_quiet(quiet)) args <- cli_arg_quiet(args)
45+
4446
args <- c(args, quarto_args)
4547

46-
res <- quarto_run(args, quiet = isTRUE(quiet), quarto_bin = quarto_bin)
48+
res <- quarto_run(args, quarto_bin = quarto_bin)
4749

4850
fromJSON(res$stdout)
4951
}

R/quarto-args.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ cli_arg_profile <- function(profile, ...) {
33
append_cli_args(arg, ...)
44
}
55

6+
is_quiet <- function(quiet) {
7+
# this option takes precedence
8+
quiet_options <- getOption("quarto.quiet", NA)
9+
if (!is.na(quiet_options)) return(quiet_options)
10+
isTRUE(quiet)
11+
}
12+
613
cli_arg_quiet <- function(...) {
714
append_cli_args("--quiet", ...)
815
}

R/quarto.R

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ quarto_version <- function() {
4747
}
4848

4949
#' @importFrom processx run
50-
quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FALSE, echo_cmd = getOption("quarto.echo_cmd", FALSE), quiet = FALSE, ..., .call = rlang::caller_env()) {
51-
# this option takes precedence
52-
if (!is.na(getOption("quarto.quiet", NA))) quiet <- getOption("quarto.quiet", NA)
53-
# if quiet, add the flag to quarto call
54-
if (quiet) {
55-
if (!cli_arg_quiet() %in% args) args <- cli_arg_quiet(args)
56-
}
50+
quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FALSE, echo_cmd = getOption("quarto.echo_cmd", FALSE), ..., .call = rlang::caller_env()) {
5751
res <- tryCatch(
5852
{
5953
processx::run(quarto_bin, args = args, echo = echo, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
@@ -67,8 +61,8 @@ quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FA
6761
invisible(res)
6862
}
6963

70-
quarto_run_what <- function(what = character(), args = character(), quarto_bin = find_quarto(), echo = FALSE, quiet = FALSE, ..., .call = rlang::caller_env()) {
71-
res <- quarto_run(quarto_bin, args = c(what, args), echo = echo, quiet = quiet, ..., .call = .call)
64+
quarto_run_what <- function(what = character(), args = character(), quarto_bin = find_quarto(), echo = FALSE, ..., .call = rlang::caller_env()) {
65+
res <- quarto_run(quarto_bin, args = c(what, args), echo = echo, ..., .call = .call)
7266
invisible(res)
7367
}
7468

R/render.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
#' override metadata. This will be merged with `metadata` if both are
3838
#' specified, with low precedence on `metadata` options.
3939
#' @param debug Leave intermediate files in place after render.
40-
#' @param quiet Suppress warning and other messages. `quarto.quiet` R options
41-
#' will take precedence in any rendering, which is useful to have verbose
42-
#' logging in pkgdown for example.
40+
#' @param quiet Suppress warning and other messages.
4341
#' @param profile [Quarto project
4442
#' profile(s)](https://quarto.org/docs/projects/profiles.html) to use. Either
4543
#' a character vector of profile names or `NULL` to use the default profile.
@@ -176,6 +174,9 @@ quarto_render <- function(input = NULL,
176174
if (isTRUE(debug)) {
177175
args <- c(args, "--debug")
178176
}
177+
if (is_quiet(quiet)) {
178+
args <- cli_arg_quiet(args)
179+
}
179180
if (!is.null(profile)) {
180181
args <- cli_arg_profile(profile, args)
181182
}
@@ -187,7 +188,7 @@ quarto_render <- function(input = NULL,
187188
}
188189

189190
# run quarto
190-
quarto_run(args, echo = TRUE, quiet = isTRUE(quiet), quarto_bin = quarto_bin)
191+
quarto_run(args, echo = TRUE, quarto_bin = quarto_bin)
191192

192193
# no return value
193194
invisible(NULL)

R/use.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ quarto_use_template <- function(template, no_prompt = FALSE, quiet = FALSE, quar
3636
# TODO: Change if / when https://github.com/quarto-dev/quarto-cli/issues/8438
3737
args <- c("template", template, "--no-prompt", quarto_args)
3838

39-
if (quarto_version() > "1.5.4" & isTRUE(quiet)) {
39+
if (quarto_version() > "1.5.4" && is_quiet(quiet)) {
4040
args <- cli_arg_quiet(args)
4141
}
4242

man/quarto_add_extension.Rd

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/quarto_create_project.Rd

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/quarto_inspect.Rd

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)