Skip to content

Commit

Permalink
changed startup message to make it suppressable
Browse files Browse the repository at this point in the history
  • Loading branch information
datapumpernickel committed May 23, 2024
1 parent 6e2442e commit 1c36b4f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ assign(
envir = ct_env
)


check_old_cache_message <- function() {
cli::cli_inform(
c(
"In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint
'v' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}',
'x' = 'Ignore this warning, a new cache is created automatically.',
'i' = "Delete your old cache manually with:",
'*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint
' ' = "and",
'*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}"), #nolint
class = "packageStartupMessage"
)
}

.onAttach <- function(libname, pkgname) {
## throw a warning, if a cache in the non-compliant directory is detected
## but only if there is actually any files in this directory
Expand All @@ -24,17 +39,8 @@ assign(
length(list.files(
rappdirs::user_cache_dir('comtradr_bulk')
)) > 0)) {
packageStartupMessage(cli::cli_bullets(
c(
"In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint
'*' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}',
'*' = 'Ignore this warning, a new cache is created automatically.',
'*' = "Delete your old cache manually with:",
'*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint
' ' = "and",
'*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}") #nolint
))
}
check_old_cache_message()
}
}


Expand Down

0 comments on commit 1c36b4f

Please sign in to comment.