Skip to contents

This function initialises a boilerplate database. By default, it creates a single unified JSON database containing all categories.

Usage

boilerplate_init(
  categories = c("measures", "methods", "results", "discussion", "appendix", "template"),
  merge_strategy = c("keep_existing", "merge_recursive", "overwrite_all"),
  data_path = NULL,
  quiet = FALSE,
  dry_run = FALSE,
  create_dirs = FALSE,
  confirm = TRUE,
  create_empty = TRUE,
  format = "json",
  project = "default"
)

Arguments

categories

Character vector. Categories to include in the database. Default is all categories: "measures", "methods", "results", "discussion", "appendix", "template".

merge_strategy

Character. How to merge with existing databases: "keep_existing", "merge_recursive", or "overwrite_all".

data_path

Character. Base path for data directory. If NULL (default), uses tools::R_user_dir("boilerplate", "data").

quiet

Logical. If TRUE, suppresses all CLI alerts. Default is FALSE.

dry_run

Logical. If TRUE, simulates the operation without writing files. Default is FALSE.

create_dirs

Logical. If TRUE, creates directories that don't exist. Default is FALSE.

confirm

Logical. If TRUE, asks for confirmation before making changes. Default is TRUE.

create_empty

Logical. If TRUE, creates empty database structures with just the template headings. Default is TRUE. Set to FALSE to use default content.

format

Character. Format to save. "json" (default) is the supported format. "rds" and "both" are no longer supported because the package does not write new RDS databases.

project

Character. Project name for organizing databases. Default is "default". Projects are stored in separate subdirectories to allow multiple independent boilerplate collections.

Value

Invisibly returns TRUE if successful.

Examples

# Create a temporary directory for examples
temp_dir <- tempdir()
data_path <- file.path(temp_dir, "boilerplate_example", "data")

# Initialise unified JSON database (new default)
boilerplate_init(
  data_path = data_path,
  create_dirs = TRUE,
  create_empty = TRUE,
  confirm = FALSE,
  quiet = TRUE
)

# Check that unified JSON file was created
list.files(data_path)
#> [1] "boilerplate_unified.json"

# Initialise with default content (JSON)
boilerplate_init(
  data_path = data_path,
  create_empty = FALSE,
  confirm = FALSE,
  quiet = TRUE
)

# Clean up
unlink(file.path(temp_dir, "boilerplate_example"), recursive = TRUE)