define_options("Whether execution should emit console output", quiet = FALSE)
opt("quiet")
define_options("Whether execution should emit console output", quiet = FALSE)
opt_source("quiet")
Sys.setenv(R_GLOBALENV_QUIET = TRUE)
opt_source("quiet")
options(globalenv.quiet = FALSE)
opt_source("quiet")
define_options("Quietly", quiet = TRUE, "Verbosity", verbose = FALSE)
# retrieve multiple options
opts(c("quiet", "verbose"))
# update multiple options, returns unmodified values
opts(list(quiet = 42, verbose = TRUE))
# next time we check their values we'll see the modified values
opts(c("quiet", "verbose"))
define_options("print quietly", quiet = TRUE)
print.example <- function(x, ...) if (!opt("quiet")) NextMethod()
example <- structure("Hello, World!", class = "example")
print(example)
# using base R options to manage temporary options
orig_opts <- options(opts_list(quiet = FALSE))
print(example)
options(orig_opts)
# using `withr` to manage temporary options
withr::with_options(opts_list(quiet = FALSE), print(example))
Run the code above in your browser using DataLab