Add --max-shown and --tree-filter for tree output#1203
Open
Shonas301 wants to merge 2 commits into
Open
Conversation
* Add --max-shown and --tree-filter flags Changes made: - add MaxShown flag (src/flags/max_shown.rs) with Configurable trait impl - add TreeFilter flag (src/flags/tree_filter.rs) mirroring IgnoreGlobs pattern - wire both flags into CLI (app.rs), Config (config_file.rs), and Flags (flags.rs) - implement tree filter logic in inner_display_tree: dirs always pass, files matched by glob - implement max_shown truncation with "... and N more" summary row - filter applied before truncation as per spec - add unit tests in max_shown.rs and tree_filter.rs - add integration tests in display.rs for truncation, filter, and combined behavior * Simplify tree filter and reduce allocations Changes made: - extract create_glob/create_glob_set to shared glob_helpers module - replace .cloned().collect() with Vec<&Meta> to avoid deep-cloning subtrees - inline has_summary as truncated > 0 - minor cleanup of summary row cell construction
Author
|
Sorry for the cold-open on this and #1202 - hope that's alright. Np if you want me to make changes on either, or if you don't think they belong in upstream. I have one more change I can PR following this that kind of ties it all together visually, lmk if it or any combination of the 3 are wanted! (picture attached) |
7 tasks
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.
Two flags I found myself wanting while manually walking large trees with
--tree.--max-shown N— caps the number of items rendered at each depth. Items pastthe cap roll up into a
... and N moresummary line. Applies per depth level,so a deep tree doesn't explode. This covers the feature request in Feature request: limit number of files shown per directory in tree mode #1188
(there it's proposed as
--max-items; I called it--max-shownsince thecap applies per depth level, not globally — happy to rename if you prefer
the
--max-itemsspelling).--tree-filter <glob>— filter files by a glob pattern. Directories alwayspass (otherwise you can't walk into them), files have to match. E.g.
--tree-filter '*.rs'.They combine:
--tree-filter '*.rs' --max-shown 2shows at most 2 matchingfiles per directory plus the "... and N more" tail.
Man page and config sample updates included.
Closes #1188.
TODO
cargo fmtdoc/samples(if applicable)doc/samples(if applicable)doc/samples(if applicable)