readline_check: Check readline input

Description Usage Arguments Value Examples

View source: R/readline_check.R

Description

Check readline input

Usage

1
2
3
4
5
6
7
8
9
readline_check(
  prompt,
  type = c("numeric", "integer", "length", "grep"),
  min = -Inf,
  max = Inf,
  warning = NULL,
  default = NULL,
  ...
)

Arguments

prompt

the prompt for readline

type

what type of check to perform, one of c("numeric", "integer", "length", "grep")

min

the minimum value

max

the maximum value

warning

an optional custom warning message

default

the default option to return if the entry is blank, NULL allows no default, the default value will be displayed after the text as [default]

...

other arguments to pass to grep

Value

the validated result of readline

Examples

1
2
3
4
5
6
7
8
## Not run: 
readline_check("Type a number: ", "numeric")
readline_check("Type two characters: ", "length", min = 2, max = 2)
readline_check("Type at least 3 characters: ", "length", min = 3)
readline_check("Type no more than 4 characters: ", "length", max = 44)
readline_check("Type a letter and a number: ", "grep", pattern = "^[a-zA-Z]\\d$")

## End(Not run)

debruine/pdsbuilder documentation built on July 8, 2020, 9:40 p.m.