Skip to content

feat: add --format json to individual check commands (#54)#55

Merged
PythonWoods-Dev merged 1 commit intoPythonWoods:mainfrom
xyaz1313:feat/format-json-individual-checks
Apr 15, 2026
Merged

feat: add --format json to individual check commands (#54)#55
PythonWoods-Dev merged 1 commit intoPythonWoods:mainfrom
xyaz1313:feat/format-json-individual-checks

Conversation

@xyaz1313
Copy link
Copy Markdown
Contributor

Summary

Adds --format json flag to individual check commands (links, orphans, snippets, references, assets). Previously only check all, score, and diff supported JSON output.

Closes #54

Changes

  • New helper: _output_json_findings() — consistent JSON serialization for any findings list
  • 5 commands updated: check links, check orphans, check snippets, check references, check assets all accept --format json
  • Exit codes preserved: JSON mode maintains the same exit-code contract (exit 1 on errors, exit 2 on security breaches, exit 3 on path traversal)
  • 6 new E2E tests: Cover JSON output structure and exit code behavior

JSON Output Format

{
  "findings": [{"rel_path": "...", "line_no": 0, "code": "...", "severity": "...", "message": "..."}],
  "summary": {"errors": 0, "warnings": 0, "info": 0, "security_incidents": 0, "security_breaches": 0, "elapsed_seconds": 0.042}
}

Testing

All existing tests pass + 6 new E2E tests.

Add --format json flag to check links, orphans, snippets, references,
and assets commands. Previously only 'check all', 'score', and 'diff'
supported JSON output.

Changes:
- Add _output_json_findings() helper for consistent JSON serialization
- Add --format parameter to all 5 individual check commands
- JSON output includes findings array and summary with error/warning counts
- Exit codes are preserved in JSON mode (exit 1 on errors, exit 2 on
  security breaches, exit 3 on path traversal incidents)
- Add 6 E2E tests covering JSON output and exit code behavior

Closes PythonWoods#54
@PythonWoods-Dev PythonWoods-Dev merged commit d96cdb8 into PythonWoods:main Apr 15, 2026
PythonWoods-Dev added a commit that referenced this pull request Apr 15, 2026
Auto-format the E2E test file added by PR #55 to comply with the
project's ruff format configuration.
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
Document --format json for individual check commands in the Unreleased
section. This feature was merged after the v0.6.1rc1 tag and will be
included in the next release.
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
docs: add PR #55 to [Unreleased] changelog (EN + IT)
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
- Fix SyntaxWarning in Shield docstring (\- → \\-), follow-up to PR #57
- Add PR #55 (--format json individual commands) to [Unreleased] (EN+IT)
- Add PR #57 (GitLab PAT detection) to [Unreleased] (EN+IT)
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
…gelog

fix: escape docstring + update [Unreleased] changelog (PR #55, #57)
@PythonWoods-Dev
Copy link
Copy Markdown
Contributor

Thanks @xyaz1313 — clean contribution! 🛡️

The helper _output_json_findings() is well-designed (DRY, consistent schema across all commands) and the exit code contract is correctly preserved in JSON mode.

One minor formatting fix was needed on test_cli_e2e.py (ruff format), addressed in PR #56. The feature is now documented in zenzic-doc PR #6 and tracked in the [Unreleased] changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --format json output option

2 participants