Files
open-reuse/open_reuse/cli.py
tegwick 12b5d83091
Some checks failed
ci / validate-registry (push) Has been cancelled
feat(cli): add open-reuse validate and register portfolio integrations
Implement Integration Definition validator CLI with schema and index checks,
pytest suite, and CI workflow. Register open-cmis-tck and issue-core-gitea in
the integration index.

Closes OPEN-WP-0003 and OPEN-WP-0004.
2026-06-24 18:25:13 +02:00

74 lines
2.0 KiB
Python

from __future__ import annotations
import argparse
import sys
from pathlib import Path
from open_reuse.validate import run_validate
def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(prog="open-reuse")
subparsers = parser.add_subparsers(dest="command", required=True)
validate = subparsers.add_parser(
"validate",
help="Validate integration definitions and registry index",
)
validate.add_argument(
"paths",
nargs="*",
type=Path,
help="Integration definition files (default: registry/integrations/*.integration.yaml)",
)
validate.add_argument(
"--root",
type=Path,
default=None,
help="open-reuse repository root (auto-detected when omitted)",
)
validate.add_argument(
"--repos-base",
type=Path,
default=None,
help="Base directory containing consuming repos for external definition checks",
)
validate.add_argument(
"--no-index",
action="store_true",
help="Skip indexes/integrations.yaml checks",
)
validate.add_argument(
"--indexed-only",
action="store_true",
help="When checking index, skip local definition drift warnings",
)
validate.add_argument(
"--fail-on-warnings",
action="store_true",
help="Exit non-zero when promotion-gate warnings are present",
)
return parser
def main(argv: list[str] | None = None) -> int:
parser = _build_parser()
args = parser.parse_args(argv)
if args.command == "validate":
targets = args.paths or None
return run_validate(
root=args.root,
targets=targets,
repos_base=args.repos_base,
fail_on_warnings=args.fail_on_warnings,
check_index=not args.no_index,
indexed_only=args.indexed_only,
)
parser.error(f"unknown command: {args.command}")
return 2
if __name__ == "__main__":
raise SystemExit(main())