Check readline input
readline_check(
prompt,
type = c("numeric", "integer", "length", "grep"),
min = -Inf,
max = Inf,
warning = NULL,
default = NULL,
...
)
the prompt for readline
what type of check to perform, one of c("numeric", "integer", "length", "grep")
the minimum value
the maximum value
an optional custom warning message
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
the validated result of readline
if(interactive()){
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$")
}