Skip to content

Commit

Permalink
Consistent reset option (#100)
Browse files Browse the repository at this point in the history
* Implement option to reset project in all create functions & re-order arguments for consistency

* Update reset documentation
  • Loading branch information
jonmcalder authored and maelle committed Jan 3, 2019
1 parent 28760cb commit d35a914
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 33 deletions.
10 changes: 7 additions & 3 deletions R/createAnalysisProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
createAnalysisProject <- function(name, title = NULL,
folder = getwd(),
initial_status = "wip",
dirs = c("data", "analysis", "outputs"),
packagedeps = "packrat",
git = TRUE,
reset = TRUE,
external_setup = list(
git_service = "GitHub",
login = gh::gh_whoami()$login,
private = FALSE,
protocol = "ssh",
ci_activation = "travis"
),
dirs = c("data", "analysis", "outputs")) {
reset = TRUE) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")
Expand Down Expand Up @@ -61,6 +61,10 @@ createAnalysisProject <- function(name, title = NULL,
message(sprintf("Oops! An error was found and the `%s` directory was deleted", name)) # nolint
}
)
reset_proj(current_proj)

if (reset) {
reset_proj(current_proj)
}

invisible(TRUE)
}
5 changes: 2 additions & 3 deletions R/createBasicProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' "travis" means calling \code{usethis::use_travis()} and adding the Travis
#' badge to the README.
#' }
#' @param reset whether to reset the project to current project
#' @param reset Whether to reset the project to current project
#'
#' @export
#'
Expand All @@ -37,8 +37,7 @@
#' list.files(file.path(folder, "doggos"))
#' unlink(file.path(folder, "doggos"))
#' }
createBasicProject <- function(name,
title = NULL,
createBasicProject <- function(name, title = NULL,
folder = getwd(),
initial_status = "wip",
packagedeps = "checkpoint",
Expand Down
16 changes: 11 additions & 5 deletions R/createPackageProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#' \item \code{ci_activation} Only NULL, and "travis" are supported at the moment.
#' "travis" means calling \code{usethis::use_travis()} and adding the Travis
#' badge to the README.
#' }#' @param title "What the Project Does (One Line, Title Case)"
#' If NULL, a random one will be generated.
#' }
#' @param reset Whether to reset the project to current project
#'
#' @export
#'
Expand All @@ -33,7 +33,8 @@
#' createPackageProject(
#' name = "doggos", title = "Counting cute dogs",
#' folder = folder,
#' git = TRUE, external_setup = NULL
#' git = TRUE, external_setup = NULL,
#' reset = TRUE
#' )
#' list.files(file.path(folder, "doggos"))
#' unlink(file.path(folder, "doggos"))
Expand All @@ -51,7 +52,8 @@ createPackageProject <- function(name, title = NULL,
private = FALSE,
protocol = "ssh",
ci_activation = "travis"
)) {
),
reset = TRUE) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")
Expand Down Expand Up @@ -162,6 +164,10 @@ createPackageProject <- function(name, title = NULL,
}
)
}
reset_proj(current_proj)

if (reset) {
reset_proj(current_proj)
}

invisible(TRUE)
}
9 changes: 6 additions & 3 deletions R/createTrainingProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#' list.files(file.path(folder, "doggos"))
#' unlink(file.path(folder, "doggos"))
#' }
createTrainingProject <- function(name, folder = getwd(),
createTrainingProject <- function(name, title = NULL,
folder = getwd(),
initial_status = "wip",
dirs = c("data", "handouts", "slides"),
handoutEngine = "rmarkdown",
Expand All @@ -37,7 +38,6 @@ createTrainingProject <- function(name, folder = getwd(),
protocol = "ssh",
ci_activation = "travis"
),
title = NULL,
reset = TRUE) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
Expand Down Expand Up @@ -135,7 +135,10 @@ createTrainingProject <- function(name, folder = getwd(),
)
setup_dep_system(packagedeps)

reset_proj(current_proj)
if (reset) {
reset_proj(current_proj)
}

invisible(TRUE)
}

Expand Down
13 changes: 7 additions & 6 deletions man/createAnalysisProject.Rd

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

2 changes: 1 addition & 1 deletion man/createBasicProject.Rd

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

10 changes: 6 additions & 4 deletions man/createPackageProject.Rd

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

17 changes: 9 additions & 8 deletions man/createTrainingProject.Rd

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

0 comments on commit d35a914

Please sign in to comment.