Configuration utility for aux4. Manage YAML and JSON configuration files with get, set, and merge operations.
aux4 aux4 pkger install aux4/config
It can be a YAML or JSON file.
config.yaml
config:
dev:
host: localhost
port: 3000
prod:
host: aux4.io
port: 80
config.json
{
"config": {
"dev": {
"host": "localhost",
"port": 3000
},
"prod": {
"host": "aux4.io",
"port": 80
}
}
}
The command aux4 config get can be used to get the configuration.
> aux4 config get dev
{
"host": "localhost",
"port": 3000
}
Or specify a config file:
> aux4 config get --file config.yaml dev
{
"host": "localhost",
"port": 3000
}
> aux4 config get dev/host
localhost
Or with a specific config file:
> aux4 config get --file config.yaml dev/host
localhost
The command aux4 config set can be used to set the configuration.
> aux4 config set --name dev/host --value dev.aux4.io
Or with a specific config file:
> aux4 config set --file config.yaml --name dev/host --value dev.aux4.io
> aux4 config get dev
{
"host": "dev.aux4.io",
"port": 3000
}
The command aux4 config merge can be used to merge configurations.
> aux4 config get --file dev.yaml | aux4 config merge --file prod.yaml | jq .
{
"dev": {
"host": "localhost",
"port": 3000
},
"prod": {
"host": "aux4.io",
"port": 80
}
}
You can also save the merged result directly to a file:
> aux4 config get --file dev.yaml | aux4 config merge --file prod.yaml --save
Or merge into a specific path within the configuration:
db.json:
{
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "postgres",
"database": "postgres"
}
> cat db.json | aux4 config merge --file config.json --name dev/db | jq .
{
"dev": {
"db": {
"database": "postgres",
"host": "localhost",
"password": "postgres",
"port": 5432,
"user": "postgres"
},
"host": "localhost",
"port": 3000
}
}