R/get_confirmation.R

Defines functions get_confirmation

get_confirmation <- function(msg, default_yes=TRUE)
{
    non_default <- if(default_yes) "n" else "y"
    resp <- readline(msg)
    blank <- nchar(resp) == 0
    yes <- if(default_yes)
        !blank && substr(resp, 1, 1) != "n"
    else !blank && substr(resp, 1, 1) == "y"
    if(default_yes)
        blank || yes
    else !blank && yes
}

Try the checkpoint package in your browser

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

checkpoint documentation built on Jan. 29, 2022, 1:07 a.m.