Skip to content

Add structured validate output with text/json/yaml formats#63

Merged
MicheleBonus merged 2 commits intomainfrom
codex/extend-validate-command-with-output-formats
Mar 7, 2026
Merged

Add structured validate output with text/json/yaml formats#63
MicheleBonus merged 2 commits intomainfrom
codex/extend-validate-command-with-output-formats

Conversation

@MicheleBonus
Copy link
Copy Markdown
Owner

Motivation

  • Provide machine-readable output for the validate command so callers can consume structured results as JSON or YAML in addition to existing human-readable text.
  • Preserve existing text UX and current exit-code semantics (including --strict) while enabling automated tooling to inspect validation outcomes.

Description

  • Add --format (text|json|yaml, default text) to the validate subparser via validate_parser.add_argument.
  • Refactor _validate_command to build a structured result dict containing an overall status, per-file entries with file, status, warnings, and errors, plus top-level warnings and errors arrays.
  • Keep the existing colored text rendering when --format text is used, and emit json.dumps(result, indent=2) for json and yaml.safe_dump(result) for yaml (with a PyYAML check).
  • Preserve existing exit-code logic so --strict still causes failures on warnings and errors always return non-zero.
  • Add tests/test_cli_validate.py to assert JSON output shape and strict-mode behavior.

Testing

  • Ran pytest -q tests/test_cli_validate.py tests/test_cli_protocol_output.py tests/test_cli_plan.py and all tests passed.
  • Test summary: 7 passed (covers new JSON-shape assertions and strict vs non-strict exit behavior).

Codex Task

@MicheleBonus MicheleBonus merged commit a7fc1dc into main Mar 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant