ask_or_default: Read a Line from the Terminal, but with Default Values

Description Usage Arguments Details Value See Also Examples

View source: R/strings.R

Description

Ask a question and read from the terminal in interactive scenario

Usage

1
ask_or_default(..., default = "", end = "", level = "INFO")

Arguments

..., end, level

passed to cat2

default

default value to return in case of blank input

Details

The prompt string will ask a question, providing defaults. Users need to enter the answer. If the answer is blank (no space), then returns the default, otherwise returns the user input.

This can only be used in an interactive session.

Value

A character from the user's input, or the default value. See details.

See Also

cat2, readline, ask_yesno

Examples

1
2
3
4
if(interactive()){
ask_or_default('What is the best programming language?',
               default = 'PHP')
}

dipsaus documentation built on Sept. 6, 2021, 5:08 p.m.