#!/bin/bash
# (C) Crown copyright, Met Office. All rights reserved.
#
# This file is part of IMPROVER and is released under a BSD 3-Clause license.
# See LICENSE in the root of the repository for full licensing details.
#------------------------------------------------------------------------------
# NAME
#    improver - IMPROVER post-processing and verification operations
#
# SYNOPSIS
#    improver OPERATION [OPTIONS] [ARGS...] # Invoke an IMPROVER operation
#    improver help                     # Generic help across operations
#    improver help OPERATION           # Specific help for a particular operation
#    improver version                  # Print out version information
#
# DESCRIPTION
#    Launch particular operations for post-processing or verification of
#    meteorological data. This script is a central launcher for all
#    IMPROVER subcommands (improver-xxxx) and central help.
#
# ENVIRONMENT
#    IMPROVER_SITE_INIT     # override default location for etc/site-init file
#------------------------------------------------------------------------------

set -eu

export IMPROVER_DIR="$(cd $(dirname $0)/../ && pwd -P)"

# Apply site-specific setup if necessary.
if [[ -f "${IMPROVER_SITE_INIT:=$IMPROVER_DIR/etc/site-init}" ]]; then
    . "$IMPROVER_SITE_INIT"
fi

# Put our library and scripts in the paths.
export PATH="$IMPROVER_DIR/bin/:$PATH"
export PYTHONPATH="$IMPROVER_DIR/:${PYTHONPATH:-}"

exec python3 -m improver.cli "$@"
