message2: Enhanced alternative to message()

View source: R/message2.R

message2R Documentation

Enhanced alternative to message()

Description

Add options to set color and to end execution of code (to be used as error message)

Usage

message2(..., col = "cyan", font = 1, stop = FALSE)

Arguments

...

Message content to be printed. Multiple arguments are pasted together.

col

text color. Default is "cyan".

font

Integer. 1 for plain text (default), 2 for bold text.

stop

Logical. If TRUE, stops execution (like stop()) but without printing "Error:".

Details

This function prints colored messages to the console. If ANSI color codes are supported by the terminal, the message will be colored. Otherwise, it will be printed as plain text. If stop = TRUE, execution will be halted after printing the message.

Value

No return value, called for side effects. Prints a colored message to the console. If stop = TRUE, execution is halted after printing the message.

Examples

message2("This is a plain cyan message", col = "cyan", font = 1)
message2("This is a bold cyan message", col = "cyan", font = 2)
message2("This is a bold red message", col = "red", font = 2)

cat("this will be shown")
try(message2("This stops execution", stop = TRUE), silent = TRUE)
cat("this will be shown after the try")



statuser documentation built on April 25, 2026, 5:06 p.m.