classes/phase/options.tmpl
usage="
usage: $(basename "$0") [options] [<component(s)>]
Options:
-h show this help text
-s skip any build
-S skip consistency check against Fulgensfile
-c [all|build] clean local run directory, when a build is scheduled for execution it also does a full build
-k [component] keep comma sperarated list of components running
-t [component:type:[path|version]] run component inside [docker] container, [download] component or [local] use installed component from path
-v enable Verbose
{% for o in data %}-{{o.option}} {{o.longParam}}{{o.spaces()}}{{o.helpDesc}}
{% endfor %}
Url: {{accessUrl}}
Details for components:
{% for o in dataDetails %}{{o.componentName}} {Source:\"{{o.Source}}\", Default-Type:\"{{o.DefaultType}}\"{% if o.VersionInfo %}, Version-Info: \"{{o.VersionInfo}}\"{% endif %}}{% for d in o.detailsArray %}
-t {{d}}{% endfor %}
{% endfor %}"
cd "$(cd "$(dirname "$0")";pwd -P)"
BASE_PWD=$(pwd)
BUILD=local
while getopts ':hsSc:k:x:t:v{% for o in data %}{{o.option}}{% if o.longParam %}:{% endif %}{% endfor %}' option; do
case "$option" in
h) echo "$usage"
exit;;
s) SKIP_BUILD=YES;;
S) SKIP_HASH_CHECK=YES;;
c)
CLEAN=$OPTARG
if [ "$CLEAN" != "all" -a "$CLEAN" != "build" ]; then
echo "Illegal -c parameter" && exit 1
fi
;;
k) KEEP_RUNNING=$OPTARG;;
x) SKIP_STARTING=$OPTARG;;
t) TYPE_SOURCE=$OPTARG;;
v) VERBOSE=YES;;
{% for o in data %}
{{o.option}}) {{o.varNameToSet}}={% if o.longParam %}$OPTARG{% else %}YES{% endif %};;
{% endfor %}
:) printf "missing argument for -%s\\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1;;
\\?) printf "illegal option: -%s\\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1;;
esac
done
shift $((OPTIND - 1))
if [ -z "$1" ]; then
{% for comp in componentNames|map('Name') %}
declare START_{{comp|upper}}=YES
{% endfor %}
else
ALL_COMPONENTS=({{componentNames|map('Name')|join(' ')|upper}})
for comp in "$@"; do
compUpper=$(echo $comp | awk '{print toupper($0)}')
compValid=0
for compDefined in "${ALL_COMPONENTS[@]}"; do
if [ "$compDefined" = "$compUpper" ]; then
compValid=1
fi
done
if [ "$compValid" -eq 0 ]; then
echo "Component $comp is invalid!"
exit 1
fi
declare START_$compUpper=YES
done
fi