Package 'messages'

Title: Print Messages in the Console
Description: A collection of functions to print messages in the R console using the packages 'cli' and 'crayon'. This package is strongly inspired from the functions ui_*() of the package 'usethis'.
Authors: Nicolas Casajus [aut, cre, cph]
Maintainer: Nicolas Casajus <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2024-11-20 02:48:06 UTC
Source: https://github.com/FRBCesab/messages

Help Index


Pre-formatted messages for a custom user interface

Description

These functions are used to construct an user interface a la usethis.

These ⁠msg_*⁠ functions can be broken down into two main categories:

  • block styles: msg_line(), msg_rule(), msg_done(), msg_todo(), msg_info(), msg_warn(), msg_oops().

  • inline styles: msg_field(), msg_value(), msg_code().

Usage

msg_done(...)

msg_todo(...)

msg_info(...)

msg_warn(...)

msg_oops(...)

msg_line(...)

msg_rule(...)

msg_field(...)

msg_value(...)

msg_code(...)

Arguments

...

One or several expression (character or vector object).

Value

Print a success message.

Functions

  • msg_todo: Print a to do message.

  • msg_info: Print an informational message.

  • msg_warn: Print a warning message.

  • msg_oops: Print an error message.

  • msg_line: Print an (non-)empty message.

  • msg_rule: Print a rule message.

  • msg_field: Returns a customized code expression.

  • msg_value: Returns a customized variable value.

  • msg_code: Returns a customized code expression.

Note

Messages can be suppressed by using options(messages = FALSE). Messages can be reactivated by using: options(messages = TRUE).

Examples

## Block messages ----

msg_done("A success message")
msg_todo("A to do message")
msg_info("An informational message")
msg_warn("A warning message")
msg_oops("An error message")

msg_line()
msg_line("A message")

msg_rule("Left message")
msg_rule("Left message", , "Right message")
msg_rule("Left message", right = "Right message")
msg_rule(, "Center message")
msg_rule(center = "Center message")

## Inline messages ----

msg_done("The variable", msg_field("x"), "has been set to", msg_value(1))
msg_todo("Please use the function:", msg_code("msg_rule()"))
msg_line("Thanks for using", msg_code("messages"))
msg_line(msg_code("msg_rule()"))