#!/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 elif [[ "$@" == *".hog"* ]]; then exec python3 -m posthog.hogql.cli --run "$@" else echo "$0 - the full hog! 🦔+🐗=Hog" echo "" echo "Usage: bin/hog run .hog source code" echo " bin/hog run compiled .hoge bytecode" echo " bin/hoge [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