#!/usr/bin/env python3 """Pre-commit check entry point for the C++ template project.""" from __future__ import annotations import argparse import pathlib from collections.abc import Sequence from typing import cast from lib import common STATUS_PASS = "PASS" def main(argv: Sequence[str] | None = None) -> int: args = build_parser().parse_args(argv) root = common.find_project_root(pathlib.Path(__file__)) plan = build_plan(root) dry_run = cast(bool, args.dry_run) if dry_run: common.print_plan(plan) print(f"{STATUS_PASS}: dry-run planned pre-commit checks") return 0 common.print_plan(plan) return common.run_plans(plan, dry_run=False) def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=__doc__) _ = parser.add_argument("--dry-run", action="store_true", help="Print planned pre-commit checks without executing them.") return parser def build_plan(root: pathlib.Path) -> tuple[common.CommandPlan, ...]: return ( common.CommandPlan( label="pre-commit-fast-check", command=common.python_command(root / "scripts" / "dev_check.py", "--fast"), cwd=root, ), ) if __name__ == "__main__": raise SystemExit(main())