:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
#!/bin/bash
set -e
usage() {
echo "bin/hoglang - run and compile HogLang programs"
echo ""
echo "Usage: bin/hoglang <file.hog> run .hog source code"
echo " bin/hoglang <file.hoge> run compiled .hoge bytecode"
echo " bin/hoglang compile <file.hog> [output.hoge] compile .hog into .hoge"
echo " bin/hoglang compile <file.hog> <output.js> compile .hog into .js"
echo ""
echo "Options: bin/hoglang --debug run the debugger (Python only)"
echo " bin/hoglang --python use the Python VM"
echo " bin/hoglang --nodejs use the Node.js VM"
}
if [[ "$1" == "compile" ]]; then
shift
if [[ "$*" == *".hog"* || "$*" == *".js"* ]]; then
exec python3 -m posthog.hogql.cli --compile "$@"
fi
usage
exit 1
fi
if [[ "$*" == *".hoge"* ]]; then
if [[ "$*" == *"--python"* ]]; then
exec python3 -m common.hogvm.python.cli "$@"
elif [[ "$*" == *"--debug"* ]]; then
echo "Running in Python VM with debug mode"
exec python3 -m common.hogvm.python.cli "$@"
else # default to nodejs because it's fastest
set -- "${@/--nodejs/}"
VM_PATH="$(dirname "$0")/../common/hogvm/typescript"
CLI_PATH="$(dirname "$0")/../common/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 [[ "$*" == *"--out"* ]]; then
exec python3 -m posthog.hogql.cli --out "$@"
elif [[ "$*" == *".hog"* ]]; then
exec python3 -m posthog.hogql.cli --run "$@"
else
usage
exit 1
fi