Skip to contents

cli_quiet() is a helper to enable a quiet option in other functions.

Usage

cli_quiet(quiet = FALSE, push = FALSE, .frame = rlang::caller_env())

Arguments

quiet

If FALSE, leave cli.default_handler option unchanged. If TRUE, set cli.default_handler to suppressMessages temporaily with rlang::local_options() or permanently with rlang::push_options().

push

If TRUE, set cli.default_handler option with rlang::push_options().

.frame

The environment of a stack frame which defines the scope of the temporary options. When the frame returns, the options are set back to their original values.

Examples

test_fn <- function(quiet = FALSE) {
  cli_quiet(quiet = quiet)
  cli::cli_alert_info(
    "{.arg quiet} is {.val {quiet}}"
  )
}

options("cli.default_handler" = NULL)

test_fn()
#>  `quiet` is FALSE

test_fn(quiet = TRUE)