Skip to content

feat(cli): add --verbose scan timing summary#19

Open
Nitjsefnie wants to merge 1 commit into
FROWNINGdev:mainfrom
Nitjsefnie:feat/14-verbose-scan-timing
Open

feat(cli): add --verbose scan timing summary#19
Nitjsefnie wants to merge 1 commit into
FROWNINGdev:mainfrom
Nitjsefnie:feat/14-verbose-scan-timing

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

What changed

Adds a --verbose / -v flag to every scan-backed CLI subcommand (scan, describe, hover, list, er), registered in _add_scan_flags alongside the existing --path/--exclude flags.

When set, _load_index prints a one-line summary to stderr after the scan:

scanned 12 files in 34ms, found 8 apps / 47 models

Where the numbers come from

  • File count — a real count from parser._iter_python_files(root, excludes), the same walk scan_workspace uses internally to find models.py files, reused rather than approximated. This does mean the workspace is walked twice when -v is passed (once to count, once inside scan_workspace); it's opt-in and only runs when the flag is set, so the default path is unaffected.
  • Timingtime.perf_counter() wrapped tightly around the scan_workspace(...) call itself (a monotonic clock, not wall-clock time.time()).
  • App / model countslen(index.apps) and index.total_models() off the WorkspaceIndex the scan actually returned.

stderr-only guarantee

  • Verified end-to-end: django-orm-lens scan -v --path . --format json — stdout is clean, parseable JSON; stderr has exactly the one summary line.
  • Without -v, stderr is byte-for-byte empty (checked with wc -c).
  • A regression test also runs the same list invocation with and without -v and asserts stdout is identical in both cases (piping stays intact).

Tests

Added cli/tests/test_cli_verbose.py:

  • -v prints exactly one stderr line matching the message shape (scanned N files in Tms, found A apps / M models) with the real file/app/model counts for a synthetic 1-file, 2-model fixture.
  • Both -v and --verbose long-form work.
  • stdout is identical with/without -v (using list, which has no embedded timestamp so the comparison isn't timing-flaky).
  • No -v → stderr is empty.

No exact millisecond value is asserted anywhere (would be flaky) — only shape/presence.

Also added an ## [Unreleased] entry to CHANGELOG.md, following the existing pattern in this repo of individual feature commits recording under Unreleased ahead of a later version-bump release commit.

Gates (run from cli/)

  • .venv/bin/pytest -q48 passed (44 pre-existing + 4 new), 0 failures.
  • .venv/bin/ruff check django_orm_lens/cli.py tests/test_cli_verbose.py → the new test file is fully clean; cli.py reports the same 7 pre-existing warnings (UP035/UP045/UP006/SIM105, all typing-modernization style nits) that exist identically on main before this change — confirmed via git stash diff, none introduced by this PR.

Scope

Touches only cli/django_orm_lens/cli.py, cli/tests/test_cli_verbose.py, and CHANGELOG.md. No changes to the TypeScript/VS Code extension, package.json, or .github/.

Closes #14


Prepared with AI assistance (Claude Sonnet 5), human-reviewed before submission.

Adds --verbose/-v to every scan-backed CLI subcommand (scan, describe,
hover, list, er). After the scan, prints one line to stderr:

    scanned 12 files in 34ms, found 8 apps / 47 models

File count comes from the real file walk (parser._iter_python_files),
timing from time.perf_counter() around the scan_workspace() call, and
app/model counts from the returned WorkspaceIndex — nothing guessed.
Stdout is untouched in both the flagged and unflagged case, so piping
(e.g. `django-orm-lens list -v | xargs ...`) keeps working. Without -v,
nothing extra is printed.

Closes FROWNINGdev#14

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Nitjsefnie, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa57e873-b6f5-4765-b0f1-d379ad4bdeaf

📥 Commits

Reviewing files that changed from the base of the PR and between a92d5b1 and 44e4bed.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • cli/django_orm_lens/cli.py
  • cli/tests/test_cli_verbose.py
✨ 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.

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: --verbose flag showing scan timing + file count

1 participant