#!/usr/bin/env python3
import os
import shutil
import sys
from pathlib import Path


def main() -> int:
    uv = shutil.which("uv")
    if uv is None:
        print(
            "audita: error: uv is required to run this launcher. Install uv and run `uv sync` in the Audita project.",
            file=sys.stderr,
        )
        return 1

    project_root = Path(__file__).resolve().parent
    command = [uv, "run", "--project", str(project_root), "python", "-m", "audita", *sys.argv[1:]]
    os.execv(uv, command)
    return 1


if __name__ == "__main__":
    raise SystemExit(main())
