#!/usr/bin/env bash
# this script runs promnesia from the current repository (instead of the installed version)

set -eu

GIT_ROOT_DIR="$(cd "$(dirname "$0")" && git rev-parse --show-toplevel)"

if [[ -n "${PYTHONPATH:=}" ]]; then
    PPATH=":$PYTHONPATH"
else
    PPATH=""
fi

PPATH="$GIT_ROOT_DIR/src$PPATH"

export DIRTY_RUN='YES' # ugh.

if command -v python3 &> /dev/null; then
    PY_BIN="python3"
else
    PY_BIN="python" # warn?
fi

PYTHONPATH="$PPATH" exec "$PY_BIN" -m promnesia "$@"
