Right now we use things like
`r config$remote$prompt` module list
but this just returns NULL when the configuration variable does not exist (i.e., it does not error).
I wonder if we are not better off creating a helper function where we do some error control:
get_config <- function(..., default = '', required = TRUE) {
path <- list(...)
value <- config
for (name in path) {
if (!is.list(value) || is.null(value[[name]])) {
if (!required) return(default)
stop(
sprintf("Missing configuration value: %s", paste(path, collapse = "$")),
call. = FALSE
)
}
value <- value[[name]]
}
value
}
which could have usage like
`r get_config("remote", "prompt")` module list
This would also open the door to incremental improvement.
Right now we use things like
`r config$remote$prompt` module listbut this just returns
NULLwhen the configuration variable does not exist (i.e., it does not error).I wonder if we are not better off creating a helper function where we do some error control:
which could have usage like
`r get_config("remote", "prompt")` module listThis would also open the door to incremental improvement.