#!/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 suite-shutdown
#
# SYNOPSIS
#     rose suite-shutdown [OPTIONS] [--name=SUITE-NAME] [[--] EXTRA-ARGS ...]
#
# DESCRIPTION
#     Shutdown a running suite.
#
#     If `--name=SUITE-NAME` is not specified, the name will be determined by
#     locating a `rose-suite.conf` file in `$PWD` or its nearest parent
#     directories. In a normal suite, the basename of the (nearest parent)
#     directory containing the `rose-suite.conf` file is assumed to be the
#     suite name. In a project containing a rose stem suite, the basename of
#     the (nearest parent) directory containing the `rose-stem/rose-suite.conf`
#     file is assumed to be the suite name.
#
#     This wrapper also deals with the use case where a suite may be running on
#     dedicated servers at a site. The wrapper will make an attempt to detect
#     where the suite is running or last run.
#
# OPTIONS
#     --all
#         Shutdown all running suites. You will be prompted to confirm shutting
#         down each affected suite.
#     --name=SUITE-NAME
#         Specify the suite name.
#     --non-interactive, --yes, -y
#         Switch off interactive prompting (=answer yes to everything)
#     --quiet, -q
#         Decrement verbosity.
#     --verbose, -v
#         Increment verbosity.
#     -- --EXTRA-ARGS
#         See the cylc documentation, cylc shutdown for options and details on 
#         `EXTRA-ARGS`.
#-------------------------------------------------------------------------------
exec python2 -m rose.suite_control shutdown "$@"
