#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "browser-cookie3>=0.20.1",
#   "cyclopts>=3.0.0",
#   "mutagen>=1.47.0",
#   "requests>=2.32.0",
#   "rich>=13.7.0",
# ]
# ///
"""Development wrapper for the packaged bandcamp-plex-sync CLI."""

from __future__ import annotations

import importlib
import sys
from collections.abc import Callable
from pathlib import Path


def load_main() -> Callable[[], None]:
    """Load the installed CLI, falling back to this checkout's src directory."""
    try:
        module = importlib.import_module("bandcamp_plex_sync.cli")
    except ModuleNotFoundError:
        source_directory = Path(__file__).resolve().parents[1] / "src"
        sys.path.insert(0, str(source_directory))
        module = importlib.import_module("bandcamp_plex_sync.cli")
    return module.main


if __name__ == "__main__":
    load_main()()
