#!/bin/sh
BASE_PATH="$.SystemConfig.Services.System.Baptization"
JSON_CONFIG="$(chunk -F - extract_config | gunzip | xml2json -n | jsonfilter -e $BASE_PATH)"

print_baptization_key() {
    local key=$1
    echo "$key"=$(jsonfilter -s "$JSON_CONFIG" -e "\$.$key")
}

# If a specific key is given, print just that one
if [ "$1" = "-k" ]; then
    print_baptization_key $2
    exit 0
fi

# Otherwise, print all
eval $(jsonfilter -s "$JSON_CONFIG" -e BAPTIZATION_KEYS="\$")
for key in $BAPTIZATION_KEYS; do
    print_baptization_key $key
done
exit 0