diff --git a/src/main.py b/src/main.py index c9e839b..e2b7dcd 100644 --- a/src/main.py +++ b/src/main.py @@ -41,6 +41,8 @@ def wrap_json_envelope(data: dict, command: str, exit_code: int = 0) -> dict: def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description='Python porting workspace for the Claude Code rewrite effort') + # #180: Add --version flag to match canonical CLI contract + parser.add_argument('--version', action='version', version='claw-code 1.0.0 (Python harness)') subparsers = parser.add_subparsers(dest='command', required=True) subparsers.add_parser('summary', help='render a Markdown summary of the Python porting workspace') subparsers.add_parser('manifest', help='print the current Python workspace manifest') diff --git a/tests/test_exec_route_bootstrap_output_format.py b/tests/test_exec_route_bootstrap_output_format.py index 899e3c0..534e463 100644 --- a/tests/test_exec_route_bootstrap_output_format.py +++ b/tests/test_exec_route_bootstrap_output_format.py @@ -277,3 +277,30 @@ class TestEnvelopeExitCodeMatchesProcessExit: 'Envelope exit_code must match process exit code:\n' + '\n'.join(mismatches) ) + + +class TestMetadataFlags: + """Cycle #28: --version flag implementation (#180 gap closure).""" + + def test_version_flag_returns_version_text(self) -> None: + """--version returns version string and exits successfully.""" + result = _run(['--version']) + assert result.returncode == 0 + assert 'claw-code' in result.stdout + assert '1.0.0' in result.stdout + + def test_help_flag_returns_help_text(self) -> None: + """--help returns help text and exits successfully.""" + result = _run(['--help']) + assert result.returncode == 0 + assert 'usage:' in result.stdout + assert 'Python porting workspace' in result.stdout + + def test_help_still_works_after_version_added(self) -> None: + """Verify -h and --help both work (no regression).""" + result_short = _run(['-h']) + result_long = _run(['--help']) + assert result_short.returncode == 0 + assert result_long.returncode == 0 + assert 'usage:' in result_short.stdout + assert 'usage:' in result_long.stdout