AddTimeStamp2cli: A Decorator for Adding Timestamp to CLI Functions

View source: R/10_ts_cli.R

AddTimeStamp2cliR Documentation

A Decorator for Adding Timestamp to CLI Functions

Description

A higher-order function that wraps CLI functions to automatically prepend timestamps to their output messages. This creates a modified version of any CLI function that includes timestamp information in its output.

Usage

AddTimeStamp2cli(cli_func)

Arguments

cli_func

A CLI function from the cli package (e.g., cli_alert_info, cli_warn) that will be wrapped with timestamp functionality.

Details

This function uses force to ensure the CLI function is evaluated at creation time. The timestamp is generated using a TimeStamp() function which should be available in the execution environment and is inserted using cli's glue-like syntax "{ }".

Value

Returns a modified version of the input function that automatically adds a timestamp in the format "[{timestamp}]" to the beginning of all character messages passed to it.

See Also

CreateTimeStampCliEnv for creating a complete environment of timestamped CLI functions.

Other TimeStamp: CreateTimeStampCliEnv(), TimeStamp()

Examples

## Not run: 
# Create a timestamp-enabled version of cli_alert_info
timestamp_alert <- AddTimeStamp2cli(cli::cli_alert_info)
timestamp_alert("This message will have a timestamp")

## End(Not run)


SigBridgeRUtils documentation built on Sept. 29, 2026, 5:09 p.m.