1010# ' print after the message.
1111# ' @param text character; the text to print before the timestamp. If empty
1212# ' (default), only the timestamp is printed.
13- # ' @param n_lines integer; the number of newline characters to print after the
14- # ' message. Default is 1.
15- # ' @param time logical; whether to include the time in the timestamp. Default is
16- # ' `TRUE`. If `FALSE`, only the text is printed.
17- # ' @param date logical; whether to include the date in the timestamp. Only
13+ # ' @param msg_n_lines integer; the number of newline characters to print after
14+ # ' the message. Default is 1.
15+ # ' @param cat_timestamp logical; whether to include the time in the timestamp.
16+ # ' Default is `TRUE`. If `FALSE`, only the text is printed.
17+ # ' @param cat_date logical; whether to include the date in the timestamp. Only
1818# ' effective if `time` is `TRUE`. Default is `FALSE`, meaning only the time is
1919# ' printed. If `TRUE`, the date is printed in the format "%d/%m/%Y %X".
2020# ' @param time_zone character; the time zone to use for the timestamp. Default
2121# ' is `CET`.
2222# ' @param level integer; the level at which the message will be printed. If e.g.
2323# ' level = 1, the following string will be printed at the beginning of the
2424# ' message: " >>> ". Default is `0`.
25- # ' @param bold logical; whether to print the text in bold. Default is `FALSE`.
26- # ' @param red logical; whether to print the text in red. Default is `FALSE`.
25+ # ' @param cat_bold logical; whether to print the text in bold. Default is
26+ # ' `FALSE`.
27+ # ' @param cat_red logical; whether to print the text in red. Default is `FALSE`.
2728# ' @param ... additional arguments passed to `cat`.
2829# ' @name cat_time
2930# ' @author Ahmed El-Gabbas
3334# ' @examples
3435# ' cat_time()
3536# '
36- # ' cat_time(date = TRUE)
37+ # ' cat_time(cat_date = TRUE)
3738# '
3839# ' cat_time("time now")
3940# '
40- # ' cat_time("\n\nTime now", n_lines = 2L, level = 1L)
41+ # ' cat_time("\n\nTime now", msg_n_lines = 2L, level = 1L)
4142# '
4243# ' cat_time(
43- # ' "\ntime now", date = TRUE, bold = TRUE, red = TRUE,
44- # ' n_lines = 2L, level = 1L)
44+ # ' "\ntime now", cat_date = TRUE, cat_bold = TRUE, cat_red = TRUE,
45+ # ' msg_n_lines = 2L, level = 1L)
4546# '
4647# ' # The use of levels
4748# ' {
5253# ' }
5354
5455cat_time <- function (
55- text = " " , n_lines = 1L , time = TRUE , bold = FALSE ,
56- red = FALSE , date = FALSE , time_zone = " CET" , level = 0L , ... ) {
56+ text = " " , msg_n_lines = 1L , cat_timestamp = TRUE , cat_bold = FALSE ,
57+ cat_red = FALSE , cat_date = FALSE , time_zone = " CET" , level = 0L , ... ) {
5758
5859 # Validate inputs
5960 AllArgs <- ls(envir = environment())
@@ -63,23 +64,23 @@ cat_time <- function(
6364 stats :: setNames(AllArgs )
6465 IASDT.R :: check_args(
6566 args_all = AllArgs , args_type = " logical" ,
66- args_to_check = c(" time " , " bold " , " red " , " date " ))
67+ args_to_check = c(" cat_timestamp " , " cat_bold " , " cat_red " , " cat_date " ))
6768 IASDT.R :: check_args(
6869 args_all = AllArgs , args_type = " numeric" ,
69- args_to_check = c(" n_lines " , " level" ))
70+ args_to_check = c(" msg_n_lines " , " level" ))
7071 rm(AllArgs , envir = environment())
7172
7273 # Current time
7374 Now <- lubridate :: now(tzone = time_zone )
7475
7576 # Format date / time
76- if (date && time ) {
77+ if (cat_date && cat_timestamp ) {
7778 Now <- format(Now , " %d/%m/%Y %X" )
7879 Now2 <- paste0(" - " , Now )
79- } else if (date ) {
80+ } else if (cat_date ) {
8081 Now <- format(Now , " %d/%m/%Y" )
8182 Now2 <- paste0(" - " , Now )
82- } else if (time ) {
83+ } else if (cat_timestamp ) {
8384 Now <- format(Now , " %X" )
8485 Now2 <- paste0(" - " , Now )
8586 } else {
@@ -114,15 +115,15 @@ cat_time <- function(
114115
115116 }
116117
117- if (bold ) {
118+ if (cat_bold ) {
118119 text <- crayon :: bold(text )
119120 }
120- if (red ) {
121+ if (cat_red ) {
121122 text <- crayon :: red(text )
122123 }
123124
124125 cat(text , ... )
125- cat(rep(" \n " , n_lines ))
126+ cat(rep(" \n " , msg_n_lines ))
126127
127128 return (invisible (NULL ))
128129}
0 commit comments