Debian Codegraph @

R/options.R

raw
1
2 renv_options_resolve <- function(value, arguments) {
3
4 if (is.function(value))
5 return(do.call(value, arguments))
6
7 value
8
9 }
10
11 renv_options_override <- function(scope, key, default = NULL, extra = NULL) {
12
13 # first, check for scoped option
14 value <- getOption(paste(scope, key, sep = "."))
15 if (!is.null(value))
16 return(renv_options_resolve(value, list(extra)))
17
18 # next, check for unscoped option
19 value <- getOption(scope)
20 if (key %in% names(value))
21 return(renv_options_resolve(value[[key]], list(extra)))
22
23 # check for functional value
24 if (is.function(value))
25 return(renv_options_resolve(value, list(key, extra)))
26
27 # nothing found; use default
28 default
29
30 }