From d4b9c6211d20dbea0cae0ad3c3a49b0adae632cd Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 23 Oct 2024 17:06:45 -0700 Subject: [PATCH] SpaDES.project.ask new option --- DESCRIPTION | 4 ++-- R/SpaDES.projectOptions.R | 7 ++++++- R/setupProject.R | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bc35886..ee47043 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,8 +5,8 @@ Description: Quickly setup a 'SpaDES' project directories and add modules using URL: https://spades-project.predictiveecology.org/, https://github.com/PredictiveEcology/SpaDES.project -Date: 2024-10-22 -Version: 0.1.0.9012 +Date: 2024-10-23 +Version: 0.1.0.9013 Authors@R: c( person("Eliot J B", "McIntire", email = "eliot.mcintire@nrcan-rncan.gc.ca", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")), diff --git a/R/SpaDES.projectOptions.R b/R/SpaDES.projectOptions.R index b5edefd..6187258 100644 --- a/R/SpaDES.projectOptions.R +++ b/R/SpaDES.projectOptions.R @@ -15,7 +15,8 @@ #' give the option. Sometimes these options can be placed in the user's `.Rprofile` #' file so they persist between sessions. #' -#' The following options are used, using the prefix: `spades` +#' The following options are used, and can mostly be specified in the various `setup*` +#' functions also. #' \tabular{lcl}{ #' *OPTION* \tab *DEFAULT VALUE* \tab *DESCRIPTION* \cr #' `reproducible.cachePath` @@ -48,6 +49,9 @@ #' #' } #' +#' `SpaDES.project.ask` is currently only used when offering to clone a remote +#' github repository. Setting this to `FALSE` will prevent asking and just "do it". +#' spadesProjectOptions <- function() { pp <- getOption("spades.projectPath") if (is.null(pp)) @@ -67,6 +71,7 @@ spadesProjectOptions <- function() { defaults2 <- list( SpaDES.project.Restart = FALSE, SpaDES.project.useGit = FALSE, + SpaDES.project.ask = TRUE, SpaDES.project.gitignore = TRUE, SpaDES.project.setLinuxBinaryRepo = TRUE, SpaDES.project.standAlone = TRUE, diff --git a/R/setupProject.R b/R/setupProject.R index 7867fd0..c70795a 100644 --- a/R/setupProject.R +++ b/R/setupProject.R @@ -2591,9 +2591,10 @@ setupRestart <- function(updateRprofile, paths, name, inProject, usethis::create_project(pp, open = FALSE, rstudio = isRstudio()) } else { repo <- file.path(host, gitUserName, basenameName) - messageVerbose(paste0("The github repository already exists: ", repo), - "\nWould you like to clone it now to ", getwd(), "\nType (y)es or any other key for no: ") - out <- if (interactive()) readline() else "yes" + messageVerbose(.messages$gitRepoExistsCloneNowTxt(repo)) + # messageVerbose(paste0("The github repository already exists: ", repo), + # "\nWould you like to clone it now to ", getwd(), "\nType (y)es or any other key for no: ") + out <- if (interactive() && getOption("SpaDES.project.ask", TRUE)) readline() else "yes" if (grepl("y|yes", tolower(out))) { setwd(dirname(getwd())) unlink(basenameName, recursive = TRUE) @@ -3100,9 +3101,14 @@ checkGitRemote <- function(name, paths) { stop_quietly() } } else { - message("It looks like the remote Git repo exists (",file.path(gitUserName, name), - "). Would you like to clone it now to ", paths[["projectPath"]], "?") - cloneNow <- readline("Y or N (if N, this will stop): ") + messageVerbose(verbose = verbose, + .messages$gitRepoExistsCloneNowTxt(repo = file.path(gitUserName, name), + to = paths[["projectPath"]])) + + # message("It looks like the remote Git repo exists (",, + # "). Would you like to clone it now to ", paths[["projectPath"]], "?") + cloneNow <- if (interactive() && getOption("SpaDES.project.ask", TRUE)) readline() else "yes" + # cloneNow <- readline("Y or N (if N, this will stop): ") if (startsWith(tolower(cloneNow), "y")) { if (normalizePath(getwd()) == normalizePath(paths[["projectPath"]], mustWork = FALSE)) { stop("Cannot clone into projectPath because it already exists; please delete it; then rerun this.")