#!/usr/bin/env bash
#-------------------------------------------------------------------------------
# Copyright (C) 2012-2019 British Crown (Met Office) & Contributors.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# NAME
#     rose config
#
# SYNOPSIS
#     # Print the value of OPTION in SECTION.
#     rose config SECTION OPTION
#
#     # Print the value of OPTION in SECTION in FILE.
#     rose config --file=FILE SECTION OPTION
#
#     # Print the value of OPTION in SECTION if exists, or VALUE otherwise.
#     rose config --default=VALUE SECTION OPTION
#
#     # Print the OPTION=VALUE pairs in SECTION.
#     rose config SECTION
#
#     # Print the value of a top level OPTION.
#     rose config OPTION
#
#     # Print the OPTION keys in SECTION.
#     rose config --keys SECTION
#
#     # Print the SECTION keys.
#     rose config --keys
#
#     # Exit with 0 if OPTION exists in SECTION, or 1 otherwise.
#     rose config -q SECTION OPTION
#
#     # Exit with 0 if SECTION exists, or 1 otherwise.
#     rose config -q SECTION
#
#     # Combine the configurations in FILE1 and FILE2, and dump the result.
#     rose config --file=FILE1 --file=FILE2
#
#     # Print the value of OPTION in SECTION of the metadata associated with
#     # the specified config FILE
#     rose config --file=FILE --meta SECTION OPTION
#
#     # Print the value of a specified metadata KEY
#     rose config --meta-key=KEY
#
# DESCRIPTION
#     Parse and print rose configuration files.
#
#     With no option and no argument, print the Rose site + user configuration.
#
# OPTIONS
#     --default
#         Specify a default value.
#     --env-var-process, -E
#         Process environment variable substitution. (Only works when returning
#         a string value.)
#     --file=FILE, -f FILE
#         Each of these specifies a configuration file. If none specified, read
#         from `$THIS/../etc/rose.conf` and `$HOME/.metomi/rose.conf` (where
#         `$THIS` is the location of this command).
#     --keys, -k
#         If specified, only print the `SECTION` keys in the configuration file
#         or the `OPTION` keys in a `SECTION`.
#     --meta
#         If specified, operate on the metadata associated with the
#         configuration `FILE`.
#     --meta-key=KEY
#         If specified, prints the value of a specified metadata flag `KEY`.
#         Cannot be used in conjunction with `--file=FILE`.
#     --no-opts
#         Do not load optional configurations.
#     --print-conf
#         If specified, prints result as a Rose configuration file snippet.
#         This allows the output to be concatenated into another Rose
#         configuration file.
#     --print-ignored, -i
#         If specified, the program will print ignored `!OPTION=VALUE` where
#         relevant.
#     --quiet, -q
#         Exit with 0 if the specified `SECTION` and/or `OPTION` exist in the
#         configuration, or 1 otherwise.
#
# ENVIRONMENT VARIABLES
#     optional ROSE_META_PATH
#         Prepend `$ROSE_META_PATH` to the metadata search path.
#-------------------------------------------------------------------------------
exec python2 -m rose.config_cli "$@"
