2024-06-07 11:37:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [[ "$@" == *".hoge"* ]]; then
|
|
|
|
if [[ "$@" == *"--python"* ]]; then
|
|
|
|
exec python3 -m hogvm.python.cli "$@"
|
|
|
|
|
|
|
|
elif [[ "$@" == *"--debug"* ]]; then
|
|
|
|
echo "Running in Python VM with debug mode"
|
|
|
|
exec python3 -m hogvm.python.cli "$@"
|
|
|
|
|
|
|
|
else # default to nodejs because it's fastest
|
|
|
|
set -- "${@/--nodejs/}"
|
|
|
|
VM_PATH="$(dirname "$0")/../hogvm/typescript"
|
|
|
|
CLI_PATH="$(dirname "$0")/../hogvm/typescript/dist/cli.js"
|
|
|
|
# TODO: recompile if something changed
|
|
|
|
if [ ! -f $CLI_PATH ]; then
|
|
|
|
echo "Building TypeScript HogVM"
|
|
|
|
cd $VM_PATH
|
|
|
|
pnpm run build
|
|
|
|
cd -
|
|
|
|
fi
|
|
|
|
exec node $CLI_PATH "$@"
|
|
|
|
fi
|
2024-08-29 14:28:50 +02:00
|
|
|
elif [[ "$@" == *"--out"* ]]; then
|
|
|
|
exec python3 -m posthog.hogql.cli --out "$@"
|
2024-06-07 11:37:53 +02:00
|
|
|
elif [[ "$@" == *".hog"* ]]; then
|
|
|
|
exec python3 -m posthog.hogql.cli --run "$@"
|
|
|
|
else
|
|
|
|
echo "$0 - the full hog! 🦔+🐗=Hog"
|
|
|
|
echo ""
|
|
|
|
echo "Usage: bin/hog <file.hog> run .hog source code"
|
|
|
|
echo " bin/hog <file.hoge> run compiled .hoge bytecode"
|
|
|
|
echo " bin/hoge <file.hog> [output.hoge] compile .hog into .hoge"
|
|
|
|
echo ""
|
|
|
|
echo "Options: bin/hog --debug run the debugger (Python only)"
|
|
|
|
echo " bin/hog --python use the Python VM"
|
|
|
|
echo " bin/hog --nodejs use the Node.js VM"
|
|
|
|
exit 1
|
|
|
|
fi
|