#!/bin/bash

# Not really used
ver=

usage() {
    echo "Run as follows:"
    echo "$0 2|3|--gs2|--gs3 <wrap|..>"
    echo "e.g. $0 2"
    echo "     will generate the GS2 release"
    echo "e.g. $0 --gs3 wrap"
    echo "     will redo the stages from wrap and onward of GS3 release"
}

# The first parameter needs to be rewritten to 2|3
# https://stackoverflow.com/questions/4827690/how-can-i-change-a-command-line-argument-in-bash#4827707
if [ -z "$1" ]; then
    usage
    exit 1
elif [ "$1" = "2" ] || [ "$1" = "--gs2" ]; then
    ver=2    
    set -- "2" "${@:2}"
elif [ "$1" = "3" ] || [ "$1" = "--gs3" ]; then
    ver=3    
    set -- "3" "${@:2}"
else
    usage
    exit 1
fi

echo $0

#echo "Updated \$1: $1"
#echo "Updated full args: $@"

# Absolute path for where this script is
CAVEAT_HOME=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo "Running as: ./macos_gsbins_cron.sh $*"
cd "$CAVEAT_HOME" && ./macos_gsbins_cron.sh $*



