parse.extra {configr}R Documentation

Parse the configuration var format, and replace it by extra.list values

Description

Parse the configuration var format, and replace it by extra.list values

Usage

parse.extra(
  config,
  extra.list = list(),
  other.config = "",
  rcmd.parse = FALSE,
  bash.parse = FALSE,
  glue.parse = FALSE,
  glue.flag = "!!glue",
  global.vars.field = "global_vars"
)

Arguments

config

A list that were generated by read.config/eval.config/eval.config.merge

extra.list

A list that can replace the configuration file 'debug' by list(debug = TRUE), and debug will be setted to TRUE

other.config

Path of another configuration file that can replace the configuration file 'key:value'

rcmd.parse

Logical wheather parse '@>@str_replace('abc', 'b', 'c')@<@' in config to 'acc'

bash.parse

Logical wheather parse '#>#echo $HOME#<#' in config to your HOME PATH

glue.parse

Logical wheather parse '!!glue1:5' in config to ['1','2','3','4','5']; ['nochange', '!!glue(1:5)', 'nochange'] => ['nochange', '1', '2', '3', '4', '5', 'nochange']

glue.flag

A character flag indicating wheater run glue() function to parse (Default is !!glue)

global.vars.field

All vars defined in global.vars.field will as the extra.list params [gloval_var]

Value

A list

Examples

config.json <- system.file('extdata', 'config.json', package='configr')
config.other <- system.file('extdata', 'config.other.yaml', package='configr')
config <- read.config(config.json)
parse.extra(config, list(debug = 'TRUE'))
parse.extra(config, list(debug = 'TRUE'), other.config = config.other)
parse.extra(config, list(debug = 'TRUE'), other.config = config.other, 
rcmd.parse = TRUE)
parse.extra(config, list(debug = 'TRUE'), other.config = config.other, 
rcmd.parse = TRUE, bash.parse = TRUE)

raw <- c('a', '!!glue{1:5}', 'c')
expect.parsed.1 <- c('a', '1', '2', '3', '4', '5', 'c')
list.raw <- list(glue = raw, nochange = 1:10)
parsed <- parse.extra(list.raw, glue.parse = TRUE)

raw <- c('!!glue_numeric{1:5}')
expect.parsed.1 <- c(1, 2, 3, 4, 5)
list.raw <- list(glue = raw, nochange = 1:10)
parsed <- parse.extra(list.raw, glue.parse = TRUE)

[Package configr version 0.3.5 Index]