Prints a message to the console with a consistent tidyomics style. A package-specific prefix is automatically added based on the calling package name, followed by the message text. Different message types are displayed using appropriate styles from the cli package.

tidy_message(
  message,
  type = c("info", "success", "warning", "danger"),
  frequency = c("always", "regularly", "once"),
  frequency_id = NULL
)

Arguments

message

A character string containing the message to display.

type

The type of message to display. One of "info", "success", "warning", or "danger". Defaults to "info".

frequency

How often the message should be displayed. One of "always" (default), "regularly" (once every 8 hours), or "once" (once per R session). Passed to rlang::inform().

frequency_id

A unique identifier used to recognise the same message when frequency is not "always". Required in that case; see rlang::inform().

Value

Invisibly returns NULL. Called for side effects (printing a styled message to the console).

Details

Frequency control uses the tidyverse messaging API (cli::cli_inform() / rlang::inform()). Use frequency = "once" to show a message once per R session.

Examples

tidy_message("Loading data...", type = "info")
#>  Console says: Loading data...
tidy_message("Data loaded successfully!", type = "success")
#>  Console says: Data loaded successfully!
tidy_message("Shown once per session.", type = "warning",
             frequency = "once", frequency_id = "example-once")
#> ! Console says: Shown once per session.
#> This message is displayed once per session.