"""Cross-platform task runner for Windows/Unix.""" import pathlib import shutil import subprocess import sys def run(cmd: str) -> None: """Run a shell command.""" result = subprocess.run(cmd, shell=True) if result.returncode: sys.exit(result.returncode) def install() -> None: run("uv sync") run("uv run pre-commit install") def check() -> None: run("uv lock --locked") run("uv run ruff check .") run("uv run ruff format --check .") run("uv run mypy src/main.py") run("uv run deptry .") def test() -> None: run("uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=term-missing") def run_main() -> None: run("uv run python src/main.py") def clean() -> None: for target in [".venv", "__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache"]: path = pathlib.Path(target) if path.is_dir(): shutil.rmtree(path) TASKS = { "install": install, "check": check, "test": test, "run": run_main, "clean": clean, } if __name__ == "__main__": task = sys.argv[1] if len(sys.argv) > 1 else "run" if task in TASKS: TASKS[task]() else: print(f"Unknown task: {task}. Available: {', '.join(TASKS)}") sys.exit(1)