Skip to content

feat(cli): add JSON output to the list subcommand#16

Merged
FROWNINGdev merged 1 commit into
FROWNINGdev:mainfrom
Nitjsefnie:feat/8-list-json-output
Jul 18, 2026
Merged

feat(cli): add JSON output to the list subcommand#16
FROWNINGdev merged 1 commit into
FROWNINGdev:mainfrom
Nitjsefnie:feat/8-list-json-output

Conversation

@Nitjsefnie

@Nitjsefnie Nitjsefnie commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds JSON output support to the django-orm-lens list subcommand.

Flag form

I chose --format json (and -f json) rather than a separate --json flag because that is exactly how scan and describe already expose structured output. Using the same --format mechanism keeps the CLI predictable and avoids inventing a parallel flag.

Output shape

django-orm-lens list --format json prints:

[
  {"app": "app_name", "model": "ModelName"},
  ...
]

Backward compatibility

Bare django-orm-lens list still emits one app.Model line per model — byte-for-byte unchanged.

Tests

  • Added cli/tests/test_list_command.py covering default text output and JSON output shape.
  • All existing tests pass.

Gates

  • pytest -q from cli/: 47 passed
  • ruff check django_orm_lens tests: only pre-existing lint warnings (none introduced by this change)

Closes #8

Prepared with AI assistance (Kimi K2.7 Code), human-reviewed before submission.

Summary by CodeRabbit

  • New Features

    • Added JSON output support to the CLI list command via --format json or -f json.
    • JSON results are provided as a pipe-friendly array containing application and model names.
    • Existing text output remains the default for backward compatibility.
  • Documentation

    • Added an unreleased changelog entry describing the new JSON format.
  • Tests

    • Added coverage for default text output and both JSON flag forms.

Add --format/-f flag to the list subcommand with choices text (default) and json.

JSON output is [{"app": "...", "model": "..."}, ...], matching the issue spec.

Default text output remains unchanged for backward compatibility.

Co-Authored-By: Kimi K2.7 Code <noreply@kimi.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77daf95c-e5de-4146-a9c3-450a04acae48

📥 Commits

Reviewing files that changed from the base of the PR and between a92d5b1 and 5a25d07.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • cli/django_orm_lens/cli.py
  • cli/tests/test_list_command.py

📝 Walkthrough

Walkthrough

The CLI list subcommand now accepts --format/-f with text or json, emitting either the existing text listing or a JSON array of {app, model} objects. New tests cover both formats and flag forms.

Changes

CLI list JSON output

Layer / File(s) Summary
Format parsing and output
cli/django_orm_lens/cli.py, CHANGELOG.md
Adds --format/-f, JSON serialization, validation for supported formats, and changelog documentation while preserving text as the default.
List output validation
cli/tests/test_list_command.py
Adds temporary Django model fixtures and tests for text output, JSON shape, ordering, and the short flag.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLIArguments
  participant build_parser
  participant _cmd_list
  participant stdout
  CLIArguments->>build_parser: provide --format or -f
  build_parser->>_cmd_list: pass selected format
  _cmd_list->>stdout: emit text lines or JSON array
Loading

Suggested reviewers: frowningdev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding JSON output to the CLI list subcommand.
Linked Issues check ✅ Passed The PR adds JSON output for list, preserves text output, and includes tests and the required {app, model} shape.
Out of Scope Changes check ✅ Passed The changelog update and test additions are directly related to the JSON output feature and are not out of scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@FROWNINGdev
FROWNINGdev merged commit f381ba9 into FROWNINGdev:main Jul 18, 2026
1 check passed
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.

CLI: add --json flag to list subcommand

2 participants