-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent configuration files #3
Comments
FWIW I think this is a good suggestion. Another idea would be to have the fallback in the home directory, possibly prefixed with
Something like fallback <- function(..., appname, file = "config.yml", use_parent = TRUE) {
res <- tryCatch(config::get(..., file = file, use_parent = use_parent), error = function(e) NULL)
if (!is.null(res)) {
return(res)
}
for (file_path in c(
file.path(rappdirs::user_config_dir(appname), file),
file.path(Sys.getenv("HOME"), paste0(".", file)))) {
res <- tryCatch(config::get(..., file = file_path, use_parent = FALSE), error = function(e) NULL)
if (!is.null(res)) {
return(res)
}
}
NULL
} |
The user's application directories are already in the home directory, so I would personally omit 4. ❯ rappdirs::user_log_dir(os = "unix")
[1] "/Users/gaborcsardi/.cache/log"
❯ rappdirs::user_data_dir(os = "unix")
[1] "/Users/gaborcsardi/.local/share"
❯ rappdirs::user_config_dir(os = "unix")
[1] "/Users/gaborcsardi/.config"
❯ rappdirs::user_cache_dir(os = "unix")
[1] "/Users/gaborcsardi/.cache" |
Btw. 4. is probably also included in 2... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Via https://github.com/hadley/rappdirs? So that a config file survives the re-install of a package or project.
I am not sure if this is in the scope of
config
, just an idea. I am also not sure how it would work together with the current mechanism of looking for the config file in the parent directories.The text was updated successfully, but these errors were encountered: