R/parse_strategy_verbose.R

Defines functions parse_strategy_verbose

#' Parse Verbosity Level Strategy
#'
#' @param strategy Character string specifying the verbosity level.
#' @keywords internal
#' @noRd
parse_strategy_verbose <- function(strategy) {
  if (isTRUE(strategy)) {
    strategy <- "full"
  }
  if (isFALSE(strategy)) {
    strategy <- "silent"
  }

  if (isTRUE(length(strategy) > 1L)) {
    strategy <- strategy[1]
  }
  verbose_flags <- switch(
    EXPR = strategy,
    silent = list(cmd = FALSE, output = FALSE),
    cmd = list(cmd = TRUE, output = FALSE),
    output = list(cmd = FALSE, output = TRUE),
    full = list(cmd = TRUE, output = TRUE),
    cli::cli_abort(
      message = c(
        `x` = 'Invalid `verbose` argument: {.code verbose = "{strategy}"}'
      ),
      class = "condathis_error_invalid_verbose"
    )
  )
  return(verbose_flags)
}

Try the condathis package in your browser

Any scripts or data that you put into this service are public.

condathis documentation built on April 12, 2025, 2:01 a.m.