lesson_rename: lesson_rename

View source: R/lesson_rename.R

lesson_renameR Documentation

lesson_rename

Description

Scenario where working title changes midway through project development. Does several things:

  1. Renames top-level folder of the lesson with "new_proj_name"

  2. Finds and renames all file names to found in the project folder e.g. OldShortTitle_yadayada.* -> NewShortTitle_yadayada. This is done locally using Google Drive for Desktop virtualization of the Lessons Folder

  3. Changes name of GitHub Repo at galacticpolymath/ and galacticpolymath/catalog to "new_proj_name"

  4. Reassociates lesson folder to new GitHub name with gh_reset_remote()

  5. Changes the ShortTitle and GPCatalogURL and GitHubURL items in front-matter.yml using update_fm().

Usage

lesson_rename(
  new_ShortTitle,
  new_proj_name,
  WD = "?",
  curr_ShortTitle,
  just_files = FALSE,
  change_this = NULL,
  only_rename_prefixes = TRUE,
  preserve_spaces = FALSE,
  run_check_wd = TRUE,
  force_init_capital = TRUE,
  exclude_TEST = TRUE
)

Arguments

new_ShortTitle

New ShortTitles to be swapped out in lesson project file names. If blank, will try to guess by ignoring terminal "_suffixes"

new_proj_name

The new name you want to give the selected project

WD

a virtualized path to the lesson you want to rename. Easiest to specify "?" which will invoke pick_lesson(). MUST be the same as the lesson project is named on https://github.com/galacticpolymath.

curr_ShortTitle

Current ShortTitle prefixed to lesson project files. If missing, will try to read this from ShortTitle in the existing front-matter.yml

just_files

logical; Default=FALSE; Do you want to JUST rename file prefixes, given the ShortTitle? If TRUE, this skips:

  • renaming top-level project folder

  • renaming associated GitHub project

  • pushing changes to GitHub

change_this

passed to update_fm() if you want to make any other changes to front matter. Must be a list of values to change in the front matter before rebuilding. Default=NULL. Example: list(Title="Stormy Misty's Foal") would change the title of the lesson to the name of a horsey book If WD=="all", make sure you set this to something you want to change for everything.

only_rename_prefixes

Do you want to only change project files with the ShortTitle at the beginning (and also end) of the filename? (Could avoid accidental replacements if short title is a common phrase); default=TRUE

preserve_spaces

if some files have a space in the 'Short Title', do you want to preserve this? default=FALSE

run_check_wd

logical; do you want to run check_wd()? Basically looks for files and folders you expect in a valid lesson project. default=TRUE

force_init_capital

do you want to force the output to start with a capital letter? default=FALSE

exclude_TEST

default=T; excludes test repositories. Passed to pick_lesson()

Details

Assumes that you have Google Drive for Desktop set up with access to Lessons/ folder; github and gh CLI set up with proper permissions with GP GitHub. Will ignore case to account for different user behaviors.


galacticpolymath/GPpub documentation built on April 5, 2025, 6:04 p.m.