These functions are used to construct the user interface of usethis. Use
them in your own package so that your use_ functions work the same way
as usethis.
The ui_ functions can be broken down into four main categories:
block styles:
ui_line(),ui_done(),ui_todo(),ui_oops(),ui_info().conditions:
ui_stop(),ui_warn().inline styles:
ui_field(),ui_value(),ui_path(),ui_code(),ui_unset().
The question functions ui_yeah() and ui_nope() have their own help page.
Usage
ui_line(x = character(), .envir = parent.frame())
ui_todo(x, .envir = parent.frame())
ui_done(x, .envir = parent.frame())
ui_oops(x, .envir = parent.frame())
ui_info(x, .envir = parent.frame())
ui_code_block(x, copy = rlang::is_interactive(), .envir = parent.frame())
ui_stop(x, .envir = parent.frame())
ui_warn(x, .envir = parent.frame())
ui_silence(code)
ui_field(x)
ui_value(x)
ui_path(x, base = NULL)
ui_code(x)
ui_unset(x = "unset")Arguments
- x
A character vector.
For block styles, conditions, and questions, each element of the vector becomes a line, and the result is processed by
glue::glue(). For inline styles, each element of the vector becomes an entry in a comma separated list.- .envir
Used to ensure that
glue::glue()gets the correct environment. For expert use only.- copy
If
TRUE, the session is interactive, and the clipr package is installed, will copy the code block to the clipboard.- code
Code to execute with usual UI output silenced.
- base
If specified, paths will be displayed relative to this path.
Value
The block styles, conditions, and questions are called for their side-effect. The inline styles return a string.
Silencing output
All UI output (apart from ui_yeah()/ui_nope() prompts) can be silenced
by setting options(usethis.quiet = TRUE). Use ui_silence() to silence
selected actions.
See also
Other user interface functions:
ui-questions
Examples
new_val <- "oxnard"
ui_done("{ui_field('name')} set to {ui_value(new_val)}")
#> ✔ name set to 'oxnard'
ui_todo("Redocument with {ui_code('devtools::document()')}")
#> • Redocument with `devtools::document()`
ui_code_block(c(
"Line 1",
"Line 2",
"Line 3"
))
#> Line 1
#> Line 2
#> Line 3
