R/skeleton.R

Defines functions bs2skel

bs2skel <- function(path, ...) {

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

  # generate header
  header <- c(
    "# This file was generated by a call to 'ptexamples::hello_world()'.",
    "# The following inputs were received:",
    ""
  )

  # collect inputs
  dots <- list(...)
  text <- lapply(seq_along(dots), function(i) {
    key <- names(dots)[[i]]
    val <- dots[[i]]
    paste0(key, ": ", val)
  })

  # collect into single text string
  contents <- paste(
    paste(header, collapse = "\n"),
    paste(text, collapse = "\n"),
    sep = "\n"
  )

  # write to index file
  writeLines(contents, con = file.path(path, "INDEX"))
}
koncina/bs2site documentation built on Sept. 23, 2019, 6:54 p.m.