unitizer_prompt | R Documentation |
Different functions used in different contexts to capture user input.
unitizer_prompt
, navigate_prompt
, and review_prompt
are
more advanced and allow evaluation of arbitrary expressions, in addition to
searching for specific commands such as "Y", "N", etc. simple_prompt
only matches along specified values.
unitizer_prompt(
text,
browse.env = baseenv(),
help = character(),
help.opts = character(),
valid.opts,
hist.con = NULL,
exit.condition = function(exp, env) FALSE,
global,
warn.sticky = FALSE,
...
)
navigate_prompt(
x,
curr.id,
text,
browse.env1 = globalenv(),
browse.env2 = globalenv(),
help = character(),
help.opts = character(),
valid.opts,
warn.sticky = FALSE
)
review_prompt(x, nav.env)
simple_prompt(
message,
values = c("Y", "N"),
prompt = "unitizer> ",
attempts = 5L,
case.sensitive = FALSE
)
exit_fun(y, env, valid.vals)
read_line(prompt = "")
read_line_set_vals(vals)
text |
the prompt text to display |
browse.env |
the environment to evaluate user expressions in; typically
this will contain interesting objects (use |
help |
a character vector with help suggestions: the first value in the
vector is |
help.opts |
a character vector of help options |
valid.opts |
the special letters user can type to get a special action, typically a character vector where the names are one letter (though they don't actually have to be) and are looked for as user typed input; note that the quit and help options will always be appended to this |
hist.con |
connection to save history to |
exit.condition |
function used to evaluate whether user input should cause the prompt loop to exit; this function should accept two parameters:
The function can then decide to exit or not based on either the literal
expression or evaluate the expression and decide based on the result. This
is implemented this way because |
global |
unitizerGlobal or NULL, if the global state tracking object; will be used to record state after evaluating user expressions |
warn.sticky |
TRUE or FALSE (default) whether any changes to the "warn" global option made by the evaluation of an R expression under the prompt should be allowed to stick after the evaluation. Normally that option value is reset after each evaluation. |
... |
additional arguments for |
x |
a unitizerBrowse object |
curr.id |
which id we are currently browsing |
browse.env1 |
environment to have user review tests, run commands, etc |
browse.env2 |
navigation environment |
nav.env |
an environment |
message |
character ask the user a question |
values |
character valid responses |
prompt |
see |
attempts |
how many times to try before erroring |
case.sensitive |
whether to care about case sensitivity when matching user input |
The set-up is intended to replicate something similar to what happens when
code hits a browse()
statement. User expressions are evaluated
and output to screen, and special expressions as described above cause the
evaluation loop to terminate.
navigate_prompt
is just a wrapper around unitizer_prompt
that
provides the special shortcuts to navigate to other tests in the
unitizer
.
review_prompt
is also a wrapper, but used only when at the menu that
presents available test items to navigate to.
simple_prompt
simpler prompting function used to allow user to select
from pre-specified values.
exit_fun
is used as a generic function to pass to the
exit.condition
argument of unitizer_prompt
.
read_line
and read_line_set_vals
are utility functions that
are used to implement a version of readline
that can be
automated for testing.
unitizer_prompt
: mixed allowable user input
navigate_prompt
: a unitizerBrowse
object, or allowable
user input
review_prompt
: a unitizerBrowse
object, or "Q" if the
user chose to quit
simple_prompt
: one of values
as selected by user
browse_unitizer_items
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.