R/create_project.R

Defines functions create_project

Documented in create_project

#' Create an Academic Project/Paper Project
#'
#' @description \code{create_project()} provides a convenient function for creating
#' a new academic/paper project.
#'
#'
#' @param path the directory name for the project (e.g. "my-project", "dissertation", or whatever)
#' @param ... optional stuff, but you can ignore this
#'
#' @return \code{create_project()} creates a directory named with whatever is supplied in the \code{path} variable. This
#' directory will appear in the current working directory if it is executed in the command line. The contents of that
#' directory will include a skeleton project to get the user started. The user can (and must) ultimately make it their own.
#'
#' @examples
#'
#' \dontrun{
#' create_project("example")
#' create_project("dissertation")
#' }
#'
#' @export
create_project <- function(path, ...) {

  # ensure directory exists
  dir.create(path, recursive = TRUE, showWarnings = FALSE)

  # copy 'resources' folder to path
  resources = system.file('skeleton', package='steveproj')
  #
  files = list.files(resources, recursive = TRUE, include.dirs = TRUE)
  #
  source = file.path(resources, files)
  target = file.path(path, files)
  # file.copy(source, target, recursive=TRUE)
  dir.create(paste0(path,"/src"))
  dir.create(paste0(path,"/R"))
  dir.create(paste0(path,"/doc"))
  dir.create(paste0(path,"/data"))
  dir.create(paste0(path,"/inst"))
  #file.copy(resources, path)
  file.copy(source, target)
  TRUE
}

# Callback is at: inst/rstudio/templates/project/create_project.dcf
svmiller/steveproj documentation built on May 7, 2023, 9:16 p.m.