2021-02-25 17:57:49 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# ybcon start script
|
|
|
|
|
|
|
|
EXENAME=ybcon
|
|
|
|
|
2021-03-24 13:18:17 +01:00
|
|
|
scriptDir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
|
|
|
|
|
|
|
# Location of the executable
|
|
|
|
defaultBinLocation="$scriptDir/../libexec/ybcon"
|
2021-02-25 17:57:49 +01:00
|
|
|
|
|
|
|
usage() {
|
2021-02-26 20:28:53 +01:00
|
|
|
if [ "$1" = false ]; then echo "Invalid arguments, usage:"; fi
|
2021-10-20 17:26:39 +02:00
|
|
|
echo "$EXENAME [--version] [--buildInfo] [-h|--help] [--parallel] [--target=<target>] [--newlines=on/off] [-p|--printresult] <file>"
|
2021-02-26 20:28:53 +01:00
|
|
|
if [ "$1" = true ]; then
|
|
|
|
echo " --version Print the version"
|
2021-12-31 12:51:13 +01:00
|
|
|
echo " --buildInfo Print informations about how the ybcon executable was built"
|
2021-02-26 20:28:53 +01:00
|
|
|
echo " -h or --help What you're seeing right now"
|
2021-07-07 19:07:47 +02:00
|
|
|
echo " --parallel Transpile files in parallel mode"
|
2021-03-26 10:16:48 +01:00
|
|
|
echo " --target=<target> Set the transpilation target"
|
2021-10-20 17:26:39 +02:00
|
|
|
echo " --newlines=on/off Enable or disable new lines"
|
2021-02-26 20:28:53 +01:00
|
|
|
echo " -p or --printresult Enable printing the transpilation result to stdout"
|
2021-04-24 18:12:13 +02:00
|
|
|
printf "\n"
|
2021-02-26 20:28:53 +01:00
|
|
|
fi
|
2021-02-25 17:57:49 +01:00
|
|
|
}
|
|
|
|
|
2021-02-28 13:59:05 +01:00
|
|
|
usageExit() {
|
|
|
|
usage false
|
|
|
|
exit 0
|
2021-03-26 12:55:33 +01:00
|
|
|
}; helpExit() { usage true; exit 0; }
|
2021-02-28 13:59:05 +01:00
|
|
|
|
2021-02-25 17:57:49 +01:00
|
|
|
args="";
|
|
|
|
run=false;
|
|
|
|
|
|
|
|
newArgs() {
|
|
|
|
if [ "$args" = "" ]; then
|
|
|
|
args="$args$1"
|
|
|
|
else
|
|
|
|
args="$args $1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-02-25 18:52:06 +01:00
|
|
|
if [ "$#" != 0 ]; then
|
2021-02-26 20:28:53 +01:00
|
|
|
if [ "$#" = 1 ]; then
|
2021-03-26 12:55:33 +01:00
|
|
|
case "$1" in
|
|
|
|
-h | --help )
|
|
|
|
helpExit ;;
|
2021-10-20 17:26:39 +02:00
|
|
|
--version | --buildInfo )
|
2021-03-26 12:55:33 +01:00
|
|
|
run=true; args="$1" ;;
|
|
|
|
*.ybcon )
|
|
|
|
newArgs "$1"; run=true ;;
|
|
|
|
* )
|
|
|
|
usageExit ;;
|
|
|
|
esac
|
|
|
|
else
|
2021-02-26 20:28:53 +01:00
|
|
|
for it in "$@"
|
2021-03-26 12:55:33 +01:00
|
|
|
do
|
|
|
|
case "$it" in
|
2021-10-20 17:26:39 +02:00
|
|
|
-p | --printresult | --parallel | --target=* | --newlines=on | --newlines=off )
|
2021-07-08 10:37:17 +02:00
|
|
|
if test "${args#*$it}" = "$args"; then
|
2021-03-25 21:41:04 +01:00
|
|
|
newArgs "$it"
|
2021-03-26 12:55:33 +01:00
|
|
|
else
|
|
|
|
usageExit
|
|
|
|
fi ;;
|
|
|
|
*.ybcon )
|
|
|
|
newArgs "$it"
|
|
|
|
run=true ;;
|
|
|
|
* )
|
|
|
|
usageExit ;;
|
|
|
|
esac
|
|
|
|
done
|
2021-07-08 12:57:33 +02:00
|
|
|
if test "${args#*".ybcon"}" = "$args" ; then usageExit; fi
|
2021-02-26 20:28:53 +01:00
|
|
|
fi
|
2021-02-25 18:51:03 +01:00
|
|
|
else
|
2021-02-26 20:28:53 +01:00
|
|
|
usage false
|
2021-02-25 18:51:03 +01:00
|
|
|
fi
|
2021-02-25 17:57:49 +01:00
|
|
|
|
|
|
|
runIt() { eval "$1" " $args"; }
|
|
|
|
|
|
|
|
if [ "$run" = true ]; then
|
2021-03-26 12:55:33 +01:00
|
|
|
if [ -f "$defaultBinLocation" ]; then
|
2021-02-25 17:57:49 +01:00
|
|
|
runIt "$defaultBinLocation"
|
2021-07-12 14:36:46 +02:00
|
|
|
else
|
|
|
|
echo "Yerbacon executable not found at $defaultBinLocation"
|
2021-02-25 17:57:49 +01:00
|
|
|
fi
|
|
|
|
fi
|