Skip to content

Commit

Permalink
Add support for quiet in quarto use template()
Browse files Browse the repository at this point in the history
Related to quarto-dev/quarto-cli#8438 for proper `--quiet` support
  • Loading branch information
cderv committed Jan 25, 2024
1 parent 9e74d51 commit a466a93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions R/use.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' repository as described in the documentation
#' <https://quarto.org/docs/extensions/formats.html>.
#'
#' @param quiet Suppress warnings and messages.
#'
#'
#' @examples
#' \dontrun{
Expand All @@ -20,17 +22,18 @@
#' }
#'
#' @export
quarto_use_template <- function(template, no_prompt = FALSE, quarto_args = NULL) {
quarto_use_template <- function(template, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {
rlang::check_required(template)

quarto_bin <- find_quarto()

# This will ask for approval or stop installation
check_extension_approval(no_prompt, "Quarto templates", "https://quarto.org/docs/extensions/formats.html#distributing-formats")

# quarto use template does not support `--quiet` so we mimic it by suppressing `echo` in processx
# TODO: Change if / when https://github.com/quarto-dev/quarto-cli/issues/8438
args <- c("template", template, "--no-prompt", quarto_args)

quarto_use(args, quarto_bin = quarto_bin, echo = TRUE)
quarto_use(args, quarto_bin = quarto_bin, echo = !quiet)

invisible()
}
Expand Down
9 changes: 8 additions & 1 deletion man/quarto_use_template.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Installing an extension", {
dir <- withr::local_tempdir()
withr::local_dir(dir)
expect_error(quarto_use_template("quarto-journals/jss"), "explicit approval")
quarto_use_template("quarto-journals/jss", no_prompt = TRUE)
quarto_use_template("quarto-journals/jss", no_prompt = TRUE, quiet = TRUE)
expect_true(dir.exists("_extensions/quarto-journals/jss"))
expect_length(list.files(pattern = "[.]qmd$"), 1)
})

0 comments on commit a466a93

Please sign in to comment.