eval.config.merge: Merge config parameter sets by sections.

Description Usage Arguments Value See Also Examples

View source: R/merge.R

Description

Merge config parameter sets by sections.

Usage

1
2
3
4
5
eval.config.merge(
  file = Sys.getenv("R_CONFIGFILE_ACTIVE", "config.cfg"),
  sections = NULL,
  ...
)

Arguments

file

File name of configuration file to read from. Defaults to the value of the 'R_CONFIGFILE_ACTIVE' environment variable ('config.cfg' if the variable does not exist and JSON/INI/YAML/TOML format only)

sections

Need be merged parameter sets, eg. sections=c('default', 'version'), will default to all of config sections

...

Arguments for get.config.type, eval.config.sections, eval.config

Value

A list or logical FALSE indicating that is not standard JSON/INI/YAML/TOML format file

See Also

eval.config.sections which only get all of the mainly parameter sets name in config file, read.config which only read from a config as a list, eval.config which only read one sections as config obj or a value from config file.

Examples

1
2
3
4
5
6
7
8
config.json <- system.file('extdata', 'config.json', package='configr')
config.ini <- system.file('extdata', 'config.ini', package='configr')
config.yaml <- system.file('extdata', 'config.yaml', package='configr')
config.toml <- system.file('extdata', 'config.toml', package='configr')
eval.config.merge(config.json)
eval.config.merge(config.ini)
eval.config.merge(config.yaml)
eval.config.merge(config.toml)

Example output

$debug
[1] "{{debug}} {{debug2}}"

$version
[1] "0.2.3"

$raw
[1] "@>@str_replace('config','g$','gr')@<@, #>#echo configr#<#, {{key:yes_flag}}, {{yes}}, @>@str_replace('configr','r','')@<@, #># echo config#<#, {{key:no_flag}}, {{no}}"

$parsed
[1] "configr, configr, yes, 1, config, config, no, 0"

$raw_1
[1] "!!glue {1:10}"

$parsed_1
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"

$raw_2
[1] "!!glue_numeric {1:10}"

$parsed_2
 [1]  1  2  3  4  5  6  7  8  9 10

attr(,"config")
[1] "default"            "comments"           "extra_list_parse"  
[4] "other_config_parse" "rcmd_parse"         "bash_parse"        
[7] "mulitple_parse"     "glue_parse"        
attr(,"configtype")
[1] "json"
attr(,"file")
[1] "/usr/local/lib/R/site-library/configr/extdata/config.json"
$debug
[1] "{{debug}} {{debug2}}"

$version
[1] "0.2.3"

$raw
[1] "@>@str_replace('config','g$','gr')@<@, #>#echo configr#<#, {{key:yes_flag}}, {{yes}}, @>@str_replace('configr','r','')@<@, #>#echo config#<#, {{key:no_flag}}, {{no}}"

$parsed
[1] "configr, configr, yes, 1, config, config, no, 0"

$raw_1
[1] "!!glue {1:10}"

$parsed_1
[1] "'1', '2', '3', '4', '5', '6', '7', '8', '9', '10' (Not one item)"

$raw_2
[1] "!!glue_numeric {1:10}"

$parsed_2
[1] "1, 2, 3, 4, 5, 6, 7, 8, 9, 10 (Not one item)"

attr(,"config")
[1] "default"            "comments"           "extra_list_parse"  
[4] "other_config_parse" "rcmd_parse"         "bash_parse"        
[7] "mulitple_parse"     "glue_parse"        
attr(,"configtype")
[1] "ini"
attr(,"file")
[1] "/usr/local/lib/R/site-library/configr/extdata/config.ini"
$debug
[1] "{{debug}} {{debug2}}"

$version
[1] "0.2.3"

$raw
[1] "@>@str_replace('config','g$','gr')@<@, #>#echo configr#<#, {{key:yes_flag}}, {{yes}}, @>@str_replace('configr','r','')@<@, #>#echo config#<#, {{key:no_flag}}, {{no}}"

$parsed
[1] "configr, configr, yes, 1, config, config, no, 0"

$raw_1
[1] "!!glue {1:10}"

$parsed_1
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"

$raw_2
[1] "!!glue_numeric {1:10}"

$parsed_2
 [1]  1  2  3  4  5  6  7  8  9 10

attr(,"config")
[1] "default"            "comments"           "extra_list_parse"  
[4] "other_config_parse" "rcmd_parse"         "bash_parse"        
[7] "mulitple_parse"     "glue_parse"        
attr(,"configtype")
[1] "yaml"
attr(,"file")
[1] "/usr/local/lib/R/site-library/configr/extdata/config.yaml"
$version
[1] "0.2.3"

$debug
[1] "{{debug}} {{debug2}}"

$parsed_1
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"

$parsed_2
 [1]  1  2  3  4  5  6  7  8  9 10

$raw_1
[1] "!!glue {1:10}"

$raw_2
[1] "!!glue_numeric {1:10}"

$parsed
[1] "yes no"

$raw
[1] "{{key:yes_flag}} {{key:no_flag}}"

$title
[1] "TOML Example"

attr(,"config")
[1] "bash_parse"         "comments"           "default"           
[4] "extra_list_parse"   "glue_parse"         "mulitple_parse"    
[7] "other_config_parse" "title"             
attr(,"configtype")
[1] "toml"
attr(,"file")
[1] "/usr/local/lib/R/site-library/configr/extdata/config.toml"

configr documentation built on July 17, 2020, 5:07 p.m.