#!/usr/bin/env bash
# zx launcher - lightweight wrapper to call the Python CLI
DIR="$(cd "$(dirname "$0")" && pwd)"
PY="${PYTHON:-python3}"
export PYTHONPATH="$DIR/src:$PYTHONPATH"

# Check for --debug flag
DEBUG_MODE=""
if [[ " $* " =~ " --debug " ]]; then
  export ZEXUS_DEBUG=1
  DEBUG_MODE="--debug"
  echo "🐛 [DEBUG MODE] Enabled"
fi

if [ "$#" -ge 1 ] && [[ "$1" == *.zx ]]; then
  exec "$PY" "$DIR/scripts/main.py" --syntax-style=auto --advanced-parsing run "$1" $DEBUG_MODE
else
  exec "$PY" "$DIR/scripts/main.py" "$@"
fi
