Skip to contents

Get a settings value

Usage

settings_get(config, key, default = NULL)

Arguments

config

A webrarian_config object from collection_settings().

key

One string naming the setting, its levels separated by . or /, as in "build.output-dir" or "build/output_dir". Within a level, hyphens and underscores are interchangeable, except below brand, whose keys are brand.yml's own.

default

Value returned when the key is not set.

Value

The configuration value or default.

Examples

collection <- file.path(tempdir(), "webrarian-get-demo")
catalog(collection, packages = "dplyr")
#> ✔ Created directory /tmp/RtmpQU25pJ/webrarian-get-demo
#> ✔ Created _webrarian.yml
#> ✔ Added "_site/" and ".webrarian/" to .gitignore
#> ✔ Cataloged webrarian collection: "webrarian-get-demo"
#> 
#> Next steps:
#>   Move into the collection: `setwd("/tmp/RtmpQU25pJ/webrarian-get-demo")`
#>   Acquire packages: `webrarian::acquire_package("dplyr")`
#>   Acquire files: `webrarian::acquire_file("data/")`
#>   Bind: `webrarian::bind()`
#>   Reading room: `webrarian::reading_room()`
#> ℹ Or pass `path` to each call, e.g. `webrarian::bind(path =
#>   "/tmp/RtmpQU25pJ/webrarian-get-demo")`
config <- collection_settings(collection)

settings_get(config, "webr.version")
#> [1] "0.6.0"
settings_get(config, "packages.prebuilt")
#> [1] "dplyr"
settings_get(config, "files/mount-point")
#> [1] "/home/web_user"

# Keys that are not set fall back to `default`
settings_get(config, "packages.conda", default = character())
#> character(0)

unlink(collection, recursive = TRUE)