#!/usr/bin/env bash

# Copyright 2024 DLR-SC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################
# Run multiple scripts from the development tools
#
# Options:
#     run [setup ...] [check ...] [check_metadata ...] [create_metadata ...] [build_conda] [check_version] [create_docs ...]
################################################################################


# get and go to the repo root
REPO=$(git rev-parse --show-superproject-working-tree --show-toplevel | head -1)
cd $REPO


# check if development_tools are initialized
if [ "$(ls modules/development_tools/ -A)" ]; then
    # call the actual script passing all arguments
    echo "run script in $REPO"
else
    printf "\nERROR: Cannot run script as directory 'modules/development_tools' is empty,\n       please use 'git submodule update --init' to get submodule(s)\n\n"
    exit 0
fi

source modules/development_tools/run.sh "$@"
