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

Polish quarto_create_project() #206

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jennybc
Copy link

@jennybc jennybc commented Aug 20, 2024

Some tweaks inspired by playing with quarto_create_project() while looking at r-lib/usethis#1891

Potentially addresses #153

Comment on lines +21 to +22
#' @param no_prompt Do not prompt to approve the creation of the new project
#' folder.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the docs for no_prompt are inherited from quarto_add_extension() they don't really make sense here.

(In quarto_add_extension(), no_prompt means "Do not prompt to confirm approval to download external extension.")

@@ -32,14 +40,14 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt =
"This will create a new Quarto {.emph {type}} project as a folder named {.strong {name}} in {.path {xfun::normalize_path(dir)}}."
))
prompt_value <- tolower(readline(sprintf("Do you want to proceed (Y/n)? ")))
if (!prompt_value %in% "y") {
if (!prompt_value %in% c("", "y")) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see (Y/n), I think it means that the default (just hitting "enter") is "Y" for "yes". I'm pretty certain that's how it behaves in other R packages that present such a choice. As it stands, if you just hit "enter", you get an error.

Best reference I can find for this: https://askubuntu.com/a/322601

cli::cli_abort("Operation aborted.")
}
}

quarto_bin <- find_quarto()

args <- c("project", type, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL)
args <- c("project", type, name, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL)
Copy link
Author

@jennybc jennybc Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, I always get a warning, coming from the quarto cli, with no way to suppress it.

> quarto_create_project("my-first-quarto-project", dir = "~/tmp")
This will create a new Quarto default project as a folder named my-first-quarto-project in [/Users/jenny/tmp](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#).
Do you want to proceed (Y/n)? 
WARN: No 'title' for project provided in `quarto create project`. Using 'my-first-quarto-project' as default.
Creating project at /Users/jenny/tmp/my-first-quarto-project:
  - Created _quarto.yml
  - Created my-first-quarto-project.qmd

Comment on lines -3 to -6
# TODO: Fix the test once issue solve upstream
# - https://github.com/quarto-dev/quarto-cli/issues/8809
# - https://github.com/quarto-dev/quarto-r/issues/153
skip_if_quarto("1.5")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my change re: name, these tests pass for me with Quarto 1.5, so I think they can be unskipped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant