Skip to contents

Retrieve a config value from the user config or the supplied config.

Usage

get_cfg_val(key, cfg_dir = NULL, cfg_name = NULL, cfg = NULL)

Arguments

key

A single character string of hierarchical keys to look up which is flattened by separating each level of the hierarchy with a dot.

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()

Value

A list of the requested value retrieved from the config. If the key specification corresponds to a 'leaf' entry, this will be returned as a list of length 1; if it corresponds to a list, this will be returned as a list of length > 1.

Examples

# This is not a 'leaf' entry so returns a list of length > 1
x <- get_cfg_val("store.dat.raw", cfg = generate_cfg_template())

# This is a 'leaf' entry so returns a list of length 1 (character)
x <- get_cfg_val("store.dat.raw.dirs.base", cfg = generate_cfg_template())