Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI wrapper for extensions : list, remove, update #188

Open
parmsam opened this issue Jul 3, 2024 · 3 comments · May be fixed by #192
Open

Add CLI wrapper for extensions : list, remove, update #188

parmsam opened this issue Jul 3, 2024 · 3 comments · May be fixed by #192
Labels
enhancement New feature or request

Comments

@parmsam
Copy link

parmsam commented Jul 3, 2024

Something like

quarto_list_extensions <- function(quarto_args = NULL){
  quarto_bin <- quarto:::find_quarto()
  
  args <- "extensions"  
  
  x <- quarto_list(args, quarto_bin = quarto_bin)
  
  readr::read_table(x$stderr)
}


quarto_list <- function(args = character(), ...){
  quarto:::quarto_run_what("list", args = args, ...)
}
@parmsam
Copy link
Author

parmsam commented Jul 4, 2024

Similarly could add quarto_remove_extension() and quarto_update_extension(). Here's an attempt at that:

quarto_update_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {
  rlang::check_required(extension)
  
  quarto_bin <- quarto:::find_quarto()
  
  # This will ask for approval or stop installation
  approval <- quarto:::check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
  if(is.null(approval)) approval <- TRUE
  
  if (approval) {
    args <- c(extension, "--no-prompt", if (quiet) quarto:::cli_arg_quiet(), quarto_args)
    quarto_update(args, quarto_bin = quarto_bin, echo = TRUE)
  }
  
  invisible()
}

quarto_update <- function(args = character(), ...) {
  quarto:::quarto_run_what("update", args = args, ...)
}
quarto_remove_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {
  rlang::check_required(extension)
  
  quarto_bin <- quarto:::find_quarto()
  
  # This will ask for approval or stop installation
  approval <- quarto:::check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
  if(is.null(approval)) approval <- TRUE
  
  if (approval) {
    args <- c(extension, "--no-prompt", if (quiet) quarto:::cli_arg_quiet(), quarto_args)
    quarto_remove(args, quarto_bin = quarto_bin, echo = TRUE)
  }
  
  invisible()
}

quarto_remove <- function(args = character(), ...) {
  quarto:::quarto_run_what("remove", args = args, ...)
}

@cderv
Copy link
Collaborator

cderv commented Jul 4, 2024

All the wrapper usage are followed at

I have opened some issue to track list remove and update.

I did not add them yet, because this is the kind of task that I would have thought a user did not need R to run. It is done once in a while, and can be done in terminal.

What is your use case in R context for these ?

Here's an attempt at that:

PR are welcome. This is easier to review than code in an issue.

@cderv cderv mentioned this issue Jul 4, 2024
@cderv cderv changed the title Add quarto_list_extensions function Add CLI wrapper for extensions : list, remove, update Jul 4, 2024
@cderv cderv added the enhancement New feature or request label Jul 4, 2024
@parmsam
Copy link
Author

parmsam commented Jul 4, 2024

Thank you for creating those separate issues! I originally had a need for the wrapper functions in this shiny gadget that I recently created to interactively explore and manage Quarto Extensions from the official Listing.

Given that users can add extensions via the R package, it would be beneficial to enable them to list, update, and remove extensions using R as well. I envision this functionality being similar to the R package functions in {utils} (e.g., installed.packages(), update.packages(), remove.packages()), but specifically for Quarto extensions. This would provide a seamless experience for R users, allowing them to manage extensions without needing to switch to the terminal, which can be unfamiliar to some.

Sure! I can create a PR in the next few days. 😄

@parmsam parmsam linked a pull request Jul 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants