#!/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 env-cat
#
# SYNOPSIS
#     rose env-cat [OPTIONS] [FILE ...]
#
# DESCRIPTION
#     Substitute environment variables in input files and print.
#
#     If no argument is specified, read from STDIN. One `FILE` argument may be
#     `-`, which means read from STDIN.
#
#     In `match-mode=default`, the command will look for `$NAME` or `${NAME}`
#     syntax and substitute them with the value of the environment variable
#     `NAME`. A backslash in front of the syntax, e.g. `\$NAME` or `\${NAME}`
#     will escape the substitution.
#
#     In `match-mode=brace`, the command will look for `${NAME}` syntax only.
#
# OPTIONS
#     --match-mode=MODE, -m MODE
#         Specify the match mode, which can be `brace` or `default`.
#     --output=FILE, -o FILE
#         Specify an output file. If no output file is specified or if `FILE`
#         is `-`, write output to STDOUT.
#     --unbound=STRING, --undef=STRING
#         The command will normally fail on unbound (or undefined) variables.
#         If this option is specified, the command will substitute an unbound
#         variable with the value of `STRING`, (which can be an empty string),
#         instead of failing.
#-------------------------------------------------------------------------------
exec python2 -m rose.env_cat "$@"
