#!/usr/bin/env bash

# Bash harness for GSC command line tool
#
# based on similar harness for sfp
#
# gsc foo bar baz
# -> zx rundir /home/pharpend/src/ioecs/gsc \
#       foo bar baz

zx_exists() {
    command -v zx > /dev/null
}


if ! zx_exists ; then
    echo "zx not found in \$PATH"
    echo ""
    echo "Please install Erlang and zx:"
    echo "https://git.qpq.swiss/QPQ-AG/public-wiki/wiki/Install-Erlang-and-zx"
    echo ""
    echo "PATH=${PATH}"
    exit 1
fi

# script location and parent dir
FP_THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}")
FP_THIS_DIR=$(dirname -- "${FP_THIS_FILE}")
FP_PRJ_DIR=$(dirname -- "${FP_THIS_DIR}")

# simplified
zx rundir $FP_PRJ_DIR


# commented out legacy code in case need it later:
# # compute libs string
# LIB_PARTS=()
# for depname in "${LOCAL_DEPS[@]}"; do
#     LIB_PARTS+=("${depname}:${PRJ_DIR}/${depname}")
# done
# IFS=,
# LOCAL_LIBS="${LIB_PARTS[*]}"
# unset IFS
#
#LOCAL_LIBS=""
#
##echo "zx rundir $FP_CLI_DIR --libs=$LOCAL_LIBS $@"
#
##zx rundir $FP_CLI_DIR --libs=$LOCAL_LIBS $@
