Support listing directories by number of files

Based of https://github.com/bootandy/dust/pull/104

Idea is to allow users to find the number of files in each directory
instead of size.
This commit is contained in:
andy.boot
2020-08-19 00:26:34 +01:00
parent 82237c6bde
commit 4ea8d9339e
5 changed files with 56 additions and 6 deletions
+10
View File
@@ -120,6 +120,13 @@ fn main() {
.long("no-percent-bars")
.help("No percent bars or percentages will be displayed"),
)
.arg(
Arg::with_name("by_filecount")
.short("f")
.long("filecount")
.help("Directory 'size' is number of child files/dirs not disk size"),
)
.arg(Arg::with_name("inputs").multiple(true))
.get_matches();
@@ -157,6 +164,7 @@ fn main() {
Some(i) => Some(i.map(PathBuf::from).collect()),
None => None,
};
let by_filecount = options.is_present("by_filecount");
let simplified_dirs = simplify_dir_names(target_dirs);
let (permissions, nodes) = get_dir_tree(
@@ -164,6 +172,7 @@ fn main() {
&ignore_directories,
use_apparent_size,
limit_filesystem,
by_filecount,
depth,
);
let sorted_data = sort(nodes);
@@ -181,6 +190,7 @@ fn main() {
!options.is_present("reverse"),
no_colors,
options.is_present("no_bars"),
by_filecount,
tree,
);
}