Skip to contents

Most gerp functions write one template and stop. Two of them do more: grp_create() builds a whole project, and grp_batch_rename() renames every file in a folder. This article shows how each one connects to the helpers in R/.

The trees below come from stackcallr. call_tree_dir() parses the files in R/ without running them.

grp_create()

grp_create() checks the path first. check_home_dir() asks before it creates a project in the home folder, and check_nested_proj() asks before it creates one inside another project. Then the five folder functions each write their templates, and ide_call() opens the new project in RStudio or Positron.

stackcallr::call_tree_dir("../R", root = "grp_create")
█─grp_create
├─█─check_home_dir
│ └─grp_confirm
├─█─check_nested_proj
│ ├─proj_criteria
│ └─grp_confirm
├─█─grp_setup
│ └─use_grp_template
├─█─grp_code
│ └─use_grp_template
├─█─grp_data
│ └─use_grp_template
├─█─grp_dev
│ └─use_grp_template
├─█─grp_report
│ └─use_grp_template
├─use_grp_template
└─ide_call

The five folder functions (grp_setup(), grp_code(), grp_data(), grp_dev(), and grp_report()) have the same one step tree. Each one calls use_grp_template():

stackcallr::call_tree_dir("../R", root = "grp_setup")
█─grp_setup
└─use_grp_template

grp_batch_rename()

grp_batch_rename() reads the file dates with fs, then passes the names to grp_fname(). grp_fname() cleans each name with clean_stem() and adds the date prefix. Its last step, copy_result(), copies a single name to the clipboard; grp_batch_rename() turns that off with clip = FALSE.

stackcallr::call_tree_dir("../R", root = "grp_batch_rename")
█─grp_batch_rename
└─█─grp_fname
  ├─clean_stem
  └─copy_result

The Batch renaming files article shows grp_batch_rename() at work on a folder.