#!/usr/bin/env bash
# Run juanita from this checkout for development, using fades.
#
# fades creates/reuses a managed virtualenv and installs this project in
# editable mode (`-e .`), so your local changes under src/ are picked up on the
# next run with no reinstall. The `-d requests` is only there to trigger fades'
# install step (requests is a real dependency; `-e .` pulls it in anyway).
#
# Usage:
#   bin/run_dev --dry-run https://youtu.be/VIDEO_ID
#   bin/run_dev init
#   bin/run_dev --help
#
# Added a new dependency to pyproject.toml? It's picked up automatically (see
# _fades_common.sh); force it manually with FADES_REBUILD=1 bin/run_dev ...
set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"

if ! command -v fades >/dev/null 2>&1; then
    echo "error: fades is not installed. See https://github.com/PyAr/fades" >&2
    exit 1
fi

source "$repo_root/bin/_fades_common.sh"
_fades_ensure_fresh_venv dev -d requests

exec fades -d requests --pip-options="-e ." -x juanita -- "$@"
