ask_dir_create: Ask: create directory if missing

View source: R/ask.R

ask_dir_createR Documentation

Ask: create directory if missing

Description

[Experimental]

Usage

ask_dir_create(
  dir = "/path/to/directory",
  title = "Directory check",
  preamble_exists_no = c("Directory {.field {dir}} does not exist yet.",
    "Do you want to create it?"),
  preamble_exists_yes = c("Directory {.field {dir}} already exists."),
  implications_yes_addendum = character(),
  implications_yes = c("Directory {.field {dir}} will be created"),
  implications_no_addendum = character(),
  implications_no = c("Nothing ;-)"),
  step = 0,
  steps_max = 0,
  is_interactive = interactive()
)

Arguments

dir

(character or fs_path) Directory in question.

title

(character) Title for this "input block".

preamble_exists_no

(character) Preamble text.

preamble_exists_yes

(character) Preamble text.

implications_yes_addendum

(character) Additional text for the implications preamble text

implications_yes

(character) Vector with implications

implications_no_addendum

(character) Additional text for the implications preamble text

implications_no

(character) Vector with implications

step

(integer) Denote which process step this is. See cli::h1().

steps_max

(integer) Denote how many process steps there are in total. See cli::h1().

is_interactive

[logical] Interactive mode yes/no

Examples

## Not run: 
path <- ask_dir_create(dir = fs::path(tempdir(), "a/b/c"))
path %>% fs::dir_exists()

ask_dir_create(dir = fs::path(tempdir(), "a/b/c"))
# Answer with an input of 2 ("No")

ask_dir_create(dir = fs::path(tempdir(), "a/b/c"))
# Answer with an input of 3 ("Let me start over")

ask_dir_create(dir = fs::path(tempdir(), "a/b/c"))
# Answer with an input of 4 ("Exit")

## End(Not run)

rappster/clix documentation built on Aug. 16, 2022, 9:54 p.m.