Get a path value from the configuration
Usage
get_dat_path(
dat_keys,
env = NULL,
cfg_dir = NULL,
cfg_name = NULL,
cfg = NULL,
sys_env_vars = NULL
)
Arguments
- dat_keys
A character vector where each element is a key in the same format as expected by
get_cfg_val()
. These are single character strings of hierarchical keys to look up (with each level of the hierarchy separated by a dot).- env
A character string specifying the environment for which to get the path. This should be one of 'main', 'ref' or 'test'.
- cfg_dir
A character string specifying the config directory, or NULL for the default. Default: An OS-specific path for user configuration files in the user's home directory.
- cfg_name
A character string specifying the config file name, or NULL for the default. Default: 'config.yml'
- cfg
A list of nested lists, with 'leaf' nodes specifying configuration values. Default: The template config returned by
generate_cfg_template()
- sys_env_vars
A named character vector of the required system environment variables where their names are the package environments that they relate to. Note that the package environments, e.g. 'main' and 'ref', provide runtime information for using the package and should not be confused with the system environment (which specifies user-specific variables).
Value
A character string: the requested path, retrieved from the default config or the given config, if provided.
Examples
get_dat_path("store.dat.wrangled.dirs.base", cfg = generate_cfg_template())
#> Error in ensure_sys_env_vars(unname(sys_env_vars)): 2 required system environment vars are not set
#> ℹ You need a '.Renviron' file for this
#> ℹ (e.g. set VAR_NAME=<value> in .Renviron for each variable).
#> ℹ Not found in system environment:
#> ℹ 1. DIMEX_STORE
#> ℹ 2. DIMEX_STORE_REF
cfg <- get_cfg_val("store.dat.raw", cfg = generate_cfg_template())
dat_keys <- c("dirs.base", "dirs.shapefiles")
get_dat_path(dat_keys, "ref", cfg = cfg)
#> Error in ensure_sys_env_vars(unname(sys_env_vars)): 2 required system environment vars are not set
#> ℹ You need a '.Renviron' file for this
#> ℹ (e.g. set VAR_NAME=<value> in .Renviron for each variable).
#> ℹ Not found in system environment:
#> ℹ 1. DIMEX_STORE
#> ℹ 2. DIMEX_STORE_REF