diff --git a/scripts/mindmodel/cli.py b/scripts/mindmodel/cli.py new file mode 100644 index 0000000..6555aad --- /dev/null +++ b/scripts/mindmodel/cli.py @@ -0,0 +1,32 @@ +from typing import List, Optional + + +def main(argv: Optional[List[str]] = None) -> int: + """CLI wrapper that delegates to scripts.mindmodel.validator.main. + + Returns the integer exit code from the delegated main. If the + validator module is not available or raises, return a non-zero + exit code. + """ + try: + # Import here to avoid side-effects on module import + from scripts.mindmodel import validator + + # Call the validator.main if present + if hasattr(validator, "main"): + result = validator.main(argv) + # Ensure we return an int + try: + return int(result) # type: ignore + except Exception: + return 1 + else: + return 2 + except Exception: + # Import error or runtime error — return non-zero so callers + # can detect failure (tests expect non-zero on missing manifest) + return 2 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/scripts/mindmodel/test_cli.py b/tests/scripts/mindmodel/test_cli.py new file mode 100644 index 0000000..2333f24 --- /dev/null +++ b/tests/scripts/mindmodel/test_cli.py @@ -0,0 +1,14 @@ +import os + + +def test_cli_with_nonexistent_manifest(): + """Calling cli.main with a non-existent manifest should return non-zero.""" + from scripts.mindmodel import cli + + # Provide a path that is extremely unlikely to exist + fake_manifest = "/this/path/does/not/exist/manifest.json" + + code = cli.main([fake_manifest]) + + assert isinstance(code, int) + assert code != 0