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
|
2022-04-09 22:43:52 +02:00
|
|
|
echo "$EXENAME [--version] [--buildInfo] [-h|--help] [--parallel] [--target=<target>] [--newlines=on/off] [-p|--printresult] [-t|--text] <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"
|
2022-04-09 22:43:52 +02:00
|
|
|
echo " -t or --text Transpile text provided after this argument (implies -p)"
|
2023-06-12 21:31:46 +02:00
|
|
|
echo " -o or --output Output the transpiled file(s) to the specified directory"
|
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
|
|
|
|
2022-04-09 22:43:52 +02:00
|
|
|
arguments="";
|
2021-02-25 17:57:49 +01:00
|
|
|
run=false;
|
|
|
|
|
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 ;;
|
2022-04-09 22:43:52 +02:00
|
|
|
--version | --buildInfo | *.ybcon )
|
|
|
|
run=true ;;
|
2021-03-26 12:55:33 +01:00
|
|
|
* )
|
|
|
|
usageExit ;;
|
|
|
|
esac
|
|
|
|
else
|
2022-04-09 22:43:52 +02:00
|
|
|
text_provided=false
|
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 )
|
2022-04-10 00:36:00 +02:00
|
|
|
if [ "${arguments#*$it}" != "$arguments" ] && [ "${arguments%*-$it}" = "${arguments#*-$it}" ]; then
|
2021-03-26 12:55:33 +01:00
|
|
|
usageExit
|
|
|
|
fi ;;
|
2022-04-09 22:43:52 +02:00
|
|
|
-t | --text )
|
|
|
|
text_provided=true ;;
|
2021-03-26 12:55:33 +01:00
|
|
|
* )
|
2022-04-10 00:36:00 +02:00
|
|
|
if [ $text_provided = true ] || [ "${it%*.ybcon}" != "$it" ]; then
|
2022-04-09 22:43:52 +02:00
|
|
|
run=true
|
|
|
|
else
|
|
|
|
usageExit
|
|
|
|
fi ;;
|
2021-03-26 12:55:33 +01:00
|
|
|
esac
|
2022-04-09 22:43:52 +02:00
|
|
|
if [ "$arguments" != "" ]; then
|
|
|
|
arguments="$arguments "
|
|
|
|
fi
|
|
|
|
arguments="$arguments$it"
|
2021-03-26 12:55:33 +01:00
|
|
|
done
|
2022-04-09 22:43:52 +02:00
|
|
|
if test $run = false ; 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
|
|
|
|
|
|
|
if [ "$run" = true ]; then
|
2021-03-26 12:55:33 +01:00
|
|
|
if [ -f "$defaultBinLocation" ]; then
|
2022-04-09 22:43:52 +02:00
|
|
|
exec "$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
|