R/helpers.R

Defines functions clone_cheats_to_cache

#
#
#
# create_cache_location <- function(create = TRUE) {
#
#   BASE <- rappdirs::user_data_dir("CHEATSHEETS_DATA")
#   DATA_CACHE_LOC <- BASE
#
#   if(create) fs::dir_create(DATA_CACHE_LOC)
#
#   return(DATA_CACHE_LOC)
#
# }
#
#
# cache_exists <- function() {
#
#   # what should the cache location be?
#   should_be <- create_cache_location(create = FALSE)
#
#   if(fs::dir_exists(should_be)) {
#     return(c(TRUE, should_be))
#   }else{return(c(FALSE, FALSE))}
#
#
# }


clone_cheats_to_cache <- function(TEMP_PATH) {

  # TEMP_PATH <- path.expand(create_cache_location())

  # url <- "https://github.com/bradlindblad/foo"
  url <- "https://github.com/rstudio/cheatsheets"

  cli::cli_alert_success("Grabbing cheatsheets from {crayon::blue('https://posit.co/resources/cheatsheets')}")
  Sys.sleep(3)

  cli::cli_alert_info("This may take 30 seconds or more...")

  suppressMessages(
    git2r::clone(url = url, local_path = path.expand(TEMP_PATH), progress = FALSE)
  )


}

Try the cheatsheet package in your browser

Any scripts or data that you put into this service are public.

cheatsheet documentation built on May 1, 2023, 5:20 p.m.