Skip to content

Commit

Permalink
SpaDES.project.ask new option
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot McIntire committed Oct 24, 2024
1 parent ea38680 commit d4b9c62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")),
Expand Down
7 changes: 6 additions & 1 deletion R/SpaDES.projectOptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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))
Expand All @@ -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,
Expand Down
18 changes: 12 additions & 6 deletions R/setupProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit d4b9c62

Please sign in to comment.