Learn R Programming

gofigR (version 0.3.1)

read_prompt: Reads a prompt from stdin and performs optional validation

Description

Reads a prompt from stdin and performs optional validation

Usage

read_prompt(prompt, validate = NULL, attempt = 1, max_attempts = 2)

Value

input, or result of validate(input) if validate is supplied

Arguments

prompt

prompt, e.g. "Enter username: "

validate

function input => transformed input if input is valid or, error

attempt

current attempt at getting a valid input

max_attempts

maximum number of attempts