alert_utils: Validate Formatting Argument Values

View source: R/alert.R

alert_utilsR Documentation

Validate Formatting Argument Values

Description

Validate Formatting Argument Values

Usage

alert_utils()

.fmt_errs(
  st = NULL,
  bg = NULL,
  fg = NULL,
  d = " ",
  nullst = TRUE,
  nullbg = TRUE,
  nullfg = TRUE
)

.ok_fmt(x)

.choose_from(
  opts,
  mssg,
  all,
  none,
  min,
  max,
  ft,
  fs,
  fun,
  stack,
  clear,
  cancel = T
)

Arguments

st

Optional style spec.

bg

Optional background color spec.

fg

Optional foreground color spec.

d

Character scalar text delimiter.

nullst

Logical scalar indicating whether a NULL style spec is valid.

nullbg

Logical scalar indicating whether a NULL background color spec is valid.

nullfg

Logical scalar indicating whether a NULL foreground color spec is valid.

opts

An atomic vector of options to choose from.

mssg

Character scalar message to prompt the selection.

all

Logical scalar indicating whether it is valid to select all options.

none

Logical scalar indicating whether it is valid to select none of the options.

min

Non-negative integer scalar minimum number of options to select.

max

Positive integer scalar maximum numver of options to select.

ft

Character scalar title formatting spec.

fs

Character scalar subtitle formatting spec.

fun

Character scalar name of calling function.

stack

Character vector call stack.

clear

Logical scalar indicating whether to clear the console before alerting the user to the selection.

cancel

Logical scalar indicating whether cancellation of selection is valid.

Functions

  • .fmt_errs(): Validate Formatting Argument Values

  • .ok_fmt(): Validate Formatting Argument Values

  • .choose_from(): Choose from a List of Options with a Given Message and a Variety of Options

See Also

Other console: console_help()

Examples

egOkFmt <- function() {
  base::list(blank  = uj::.ok_fmt(""),
             null   = uj::.ok_fmt(NULL),
             bad.st = uj::.ok_fmt("q|r|b"),
             ok.all = uj::.ok_fmt("y|r|b"),
             padded = uj::.ok_fmt("  yellow | red | bold  "))
}
egOkFmt()
## Not run: 
  uj::.fmt_errs(),
  uj::.fmt_errs(d = 100),
  uj::.fmt_errs(st = "", bg = "", fg = ""),
  uj::.fmt_errs(st = "q", bg = "q", fg = "q"),
  uj::.fmt_errs(nullst = F, nullbg = F, nullfg = F))
  uj::.choose_from(letters, "What letter?", T, N, 0, 26, "b|s|u", "w|b|p", "console", "console", F)
  uj::.choose_from(0:9    , "What number?", F, F, 1, 1 , "r|y|b", "y|r|i", "console", "console", T, cancel = F)

## End(Not run)

j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.