feat(cli): add --verbose scan timing summary#19
Conversation
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>
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
What changed
Adds a
--verbose/-vflag to every scan-backed CLI subcommand (scan,describe,hover,list,er), registered in_add_scan_flagsalongside the existing--path/--excludeflags.When set,
_load_indexprints a one-line summary to stderr after the scan:Where the numbers come from
parser._iter_python_files(root, excludes), the same walkscan_workspaceuses internally to findmodels.pyfiles, reused rather than approximated. This does mean the workspace is walked twice when-vis passed (once to count, once insidescan_workspace); it's opt-in and only runs when the flag is set, so the default path is unaffected.time.perf_counter()wrapped tightly around thescan_workspace(...)call itself (a monotonic clock, not wall-clocktime.time()).len(index.apps)andindex.total_models()off theWorkspaceIndexthe scan actually returned.stderr-only guarantee
django-orm-lens scan -v --path . --format json— stdout is clean, parseable JSON; stderr has exactly the one summary line.-v, stderr is byte-for-byte empty (checked withwc -c).listinvocation with and without-vand asserts stdout is identical in both cases (piping stays intact).Tests
Added
cli/tests/test_cli_verbose.py:-vprints 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.-vand--verboselong-form work.-v(usinglist, which has no embedded timestamp so the comparison isn't timing-flaky).-v→ stderr is empty.No exact millisecond value is asserted anywhere (would be flaky) — only shape/presence.
Also added an
## [Unreleased]entry toCHANGELOG.md, following the existing pattern in this repo of individual feature commits recording underUnreleasedahead of a later version-bump release commit.Gates (run from
cli/).venv/bin/pytest -q→ 48 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.pyreports the same 7 pre-existing warnings (UP035/UP045/UP006/SIM105, all typing-modernization style nits) that exist identically onmainbefore this change — confirmed viagit stashdiff, none introduced by this PR.Scope
Touches only
cli/django_orm_lens/cli.py,cli/tests/test_cli_verbose.py, andCHANGELOG.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.