-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement dirs-only option #95
Closed
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8913606
Implement dirs-only option
klingtnet 3448b39
Add unit test
klingtnet 18e7877
fixup! Implement dirs-only option
klingtnet aeaf10a
fixup! Add unit test
klingtnet 6c0d598
Revert "fixup! Implement dirs-only option"
klingtnet 3333586
fixup! Implement dirs-only option
klingtnet cf40d39
Fix typos
klingtnet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use indoc::indoc; | ||
|
||
mod utils; | ||
|
||
#[test] | ||
fn level() { | ||
assert_eq!( | ||
utils::run_cmd(&[ | ||
"--sort", | ||
"name", | ||
"--no-config", | ||
"--dirs-only", | ||
"tests/data" | ||
]), | ||
indoc!( | ||
" | ||
data | ||
├─ dream_cycle | ||
├─ lipsum | ||
└─ the_yellow_king" | ||
), | ||
"Failed to print dirs-only." | ||
) | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so doing it here would result in the loss of disk usage information which is something I would still want to compute and surface to the end-user unless they supply the
--supress-size
option. We'd probably want to filter for dirs on the display step which happens somewhere here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, I'll update the PR accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition is now checked inside the
display_node
function (18e7877). With aeaf10a the unit test got adjusted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the output for the repository:
By the way, is there a way to disable colors in the ouptut? If not I'll create another a issue or PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw that this should have printed
└─
in front ofutils
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't currently a way to disable colors. Feel free to open an issue for that. I'd likely be the one to address that as unfortunately given how erdtree is built it would require a lot of tedious changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to filter this on a node and not on a display level. I'll notify you when I have a proper fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@solidiquis It's not ideal, but pruning the file nodes after the tree has been assembled seems to be the easiest way to get a dirs-only view that also includes size information. To get directory sizes we need to accumulate the size of all nodes below the directory. Commit 3333586 contains the patch that prunes the file nodes if
dirs-only
is set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the tree is now properly rendered: