#!/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-diff
#
# SYNOPSIS
#     # Display the metadata-annotated diff between two Rose config files.
#     rose config-diff FILE1 FILE2
#
#     # Display the metadata-annotated diff between two Rose config dirs.
#     rose config-diff DIR1 DIR2
#
#     # Display the diff, ignoring particular setting patterns
#     rose config-diff --ignore=namelist:foo FILE1 FILE2
#
#     # Display the diff with a particular diff tool
#     rose config-diff --diff-tool=kdiff3 FILE1 FILE2
#
#     # Display the diff with some diff tool specific options/arguments
#     rose config-diff FILE1 FILE2 -- [DIFF_OPTIONS] [DIFF_ARGUMENTS]
#
# DESCRIPTION
#     Display the metadata-annotated difference between two Rose config files.
#
# OPTIONS
#     --diff-tool=TOOL
#         Specify an alternate diff tool like diffuse or kompare.
#     --graphical, -g
#         Use a graphical diff tool.
#     --ignore=PATTERN, -i PATTERN
#         Ignore settings that contain the regular expression `PATTERN` in
#         their id. Can be specified more than once. `PATTERN` may also be a
#         key used in site or user configuration which expands to a list of
#         patterns. See `CONFIGURATION` below.
#     --meta-path=PATH, -M PATH
#         Prepend `PATH` to the metadata search path (look here first).
#         This option can be used repeatedly to load multiple paths.
#     --opt-conf-key-1=KEY, --opt-conf-key-1='(KEY)'
#         opt-conf-key for the file in the first argument.
#         Each of these switches on an optional configuration identified by
#         `KEY`. The configurations are applied first-to-last. The `(KEY)`
#         syntax denotes an optional configuration that can be missing.
#         Otherwise, the optional configuration must exist.
#     --opt-conf-key-2=KEY, --opt-conf-key-2='(KEY)'
#         `opt-conf-key` for the file in the second argument.
#         Each of these switches on an optional configuration identified by
#         `KEY`. The configurations are applied first-to-last. The `(KEY)`
#         syntax denotes an optional configuration that can be missing.
#         Otherwise, the optional configuration must exist.
#     --properties=PROPERTIES, -p PROPERTIES
#         Only display these metadata properties. This should be a comma
#         separated list of metadata options, such as title,description,help.
#
# ENVIRONMENT VARIABLES
#     optional ROSE_META_PATH
#         Prepend `$ROSE_META_PATH` to the metadata search path.
#
# ARGUMENTS
#     PATH1, PATH2
#         Two Rose configuration files or directories to compare.
#         If the path is a directory, look underneath for a Rose configuration
#         file. '-' for `PATH1` or `PATH2` denotes read in from standard input.
#     --
#         Options and arguments after a `--` token are passed directly to the
#         diff tool.
#
# CONFIGURATION
#     [external]diff-tool, [external]gdiff-tool
#        You can override the default non-graphical and graphical diff tools
#        by setting e.g::
#
#           [external]
#           diff-tool=diff3
#           gdiff-tool=kompare
#
#        in your site or user Rose configuration (`rose.conf`).
#
#     [rose-config-diff]properties, [rose-config-diff]ignore{...}
#        You can override the default metadata properties to display by
#        setting e.g::
#
#           [rose-config-diff]
#           properties=title,ns,description,help
#
#        in your site or user Rose configuration (`rose.conf`).
#        You can also set shorthand ignore patterns by setting e.g.::
#
#          [rose-config-diff]
#          ignore{foo}=namelist:bar,namelist:baz
#
#        in the same location. This will allow you to run::
#
#           rose config-diff --ignore=foo ...
#
#        instead of::
#
#           rose config-diff --ignore=namelist:bar --ignore=namelist:baz ...
#
#-------------------------------------------------------------------------------
exec python2 -m rose.config_diff "$@"
