@@ -90,6 +90,8 @@ cache_environ$epidatr_cache <- NULL
90
90
# ' variable is `EPIDATR_CACHE_LOGFILE`.
91
91
# ' @param confirm whether to confirm directory creation. default is `TRUE`;
92
92
# ' should only be set in non-interactive scripts
93
+ # ' @param startup indicates whether the function is being called on
94
+ # ' startup. Affects suppressability of the messages. Default is `FALSE`.
93
95
# ' @return [`NULL`] no return value, all effects are stored in the package
94
96
# ' environment
95
97
# ' @seealso [`clear_cache`] to delete the old cache while making a new one,
@@ -102,7 +104,8 @@ set_cache <- function(cache_dir = NULL,
102
104
days = NULL ,
103
105
max_size = NULL ,
104
106
logfile = NULL ,
105
- confirm = TRUE ) {
107
+ confirm = TRUE ,
108
+ startup = FALSE ) {
106
109
if (is.null(cache_dir )) {
107
110
cache_dir <- Sys.getenv(" EPIDATR_CACHE_DIR" , unset = rappdirs :: user_cache_dir(" R" , version = " epidatr" ))
108
111
} else if (is.null(cache_dir )) {
@@ -170,11 +173,12 @@ set_cache <- function(cache_dir = NULL,
170
173
171
174
# this is effectively a startup message, and for some reason, cli_inform doesn't support start suppression, so we're on our own
172
175
# https://github.com/r-lib/cli/issues/589 when this closes we can go back.
173
- msg <- " {cli::symbol$warn} epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not intended).
174
- {cli::symbol$info} The cache directory is {cache_dir}.
175
- {cli::symbol$info} The cache will be cleared after {days} day{ifelse(days>1,'s','')} and will be pruned if it exceeds {max_size} MB.
176
- {cli::symbol$info} The log of cache transactions is stored at {file.path(cache_dir, logfile)}."
177
- rlang :: inform(cli :: format_inline(msg ), class = " packageStartupMessage" )
176
+ cli :: cli_inform(c(
177
+ " !" = " epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not intended)." ,
178
+ " i" = " The cache directory is {cache_dir}." ,
179
+ " i" = " The cache will be cleared after {days} day{ifelse(days>1,'s','')} and will be pruned if it exceeds {max_size} MB." ,
180
+ " i" = " The log of cache transactions is stored at {file.path(cache_dir, logfile)}."
181
+ ), class = if (startup ) " packageStartupMessage" else NULL )
178
182
}
179
183
180
184
# ' Manually reset the cache, deleting all currently saved data and starting afresh
0 commit comments