Skip to end of metadata
Go to start of metadata

name-value-apply is a thin wrapper around name-value-convert --take-last functionality. It takes multiple configuration files in command line and takes only the value of last occurrence of each name in all the files.

This allow to consistently combine a bunch of configuration files; for example, you may have a default configuration file for your device, then a file with some settings customised, etc.

Examples:

> # create input files
> ( echo a=5; echo b=7 ) | name-value-convert --to=xml > default_config.xml
> ( echo a=6; echo c=8 ) | name-value-convert --to=json > customised.json

> # combine configs
> name-value-apply default_config.xml customised.json
a="6"
b="7"
c="8"
 
> # check where each path-value pair came from
> name-value-apply default_config.xml customised.json --source
a="customised.json"
b="default_config.xml"
c="customised.json"
 
> # output as json
> name-value-apply default_config.xml customised.json | name-value-convert --to json
{
    "a": "6",
    "b": "7",
    "c": "8"
}
 
> # as usual, you can do it on the fly, e.g. if you would like to override parameters with command-line options
> name-value-apply default_config.xml customised.json <( echo c=10 )
a="6"
b="7"
c="10"
  • No labels