--top <n> flag to cap table rows - #40
Open
dchaudhari7177 wants to merge 1 commit into
Open
Conversation
Owner
|
Conflict against main now — a few other PRs touching |
report/skills/agents/cost printed every row, which is long on a machine with hundreds of installed components. --top caps rows AFTER sorting, so it keeps the highest-ranked under whatever --sort is active. The cap is applied to the Report itself (used/untracked/dead) rather than in each renderer, so terminal, json, md and csv cap identically by construction. Omitting the flag is unlimited, preserving current behaviour. n is validated as a positive integer, matching the --sort validation pattern. Closes notsointresting#31
dchaudhari7177
force-pushed
the
feat/top-flag
branch
from
July 23, 2026 15:32
ba998dc to
bc247c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
report/skills/agents/costprinted every row.--top <n>caps them.Behaviour
--sortis active (--sort name --top 3gives the first three alphabetically, not the top three by fires).nis validated as a positive integer, following the existing--sortvalidation pattern:--top 0,--top 2.5,--top tenand--top=-3all exit 2 with--top expects a positive integer.Consistency across formats
Rather than capping inside each of the four renderers (easy to let one drift), the cap is applied to the
Reportitself —used/untracked/deadare sliced in onecapReporthelper that every format then renders. Terminal, json, md and csv therefore cap identically by construction. The--deadand--untrackedrow paths are capped too.Applied to
costas well asreport/skills/agents, since it is the same kind of component table and the flag surface is shared — happy to drop that if you'd rather keep it offcost.Tests
New
test/top.test.tsdrives a synthetic four-row Report (same approach assort.test.ts, since the fixture history only has one component so a cap can't be observed there): caps post-sort, caps after rather than before sorting, defaults to unlimited, is a no-op whennexceeds the row count, caps identically in all four formats, and applies toreport. Flag validation is covered intest/cli.test.ts.Typecheck and the full suite (89 passing) are green.
Closes #31