mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
fix: Dust was supposed to take multiple dir args
Dust will now work when given multiple dirs. Before this fix it would only show the largest dir.
This commit is contained in:
@@ -11,6 +11,7 @@ Dust will list the 15 biggest sub directories and will smartly recurse down the
|
|||||||
|
|
||||||
```
|
```
|
||||||
Usage: dust <dir>
|
Usage: dust <dir>
|
||||||
|
Usage: dust <dir> <another_dir> <and_more>
|
||||||
Usage: dust -s <dir> (apparent-size - shows the length of the file as opposed to the amount of disk space it uses)
|
Usage: dust -s <dir> (apparent-size - shows the length of the file as opposed to the amount of disk space it uses)
|
||||||
Usage: dust -n 30 <dir> (Shows 30 directories not 15)
|
Usage: dust -n 30 <dir> (Shows 30 directories not 15)
|
||||||
```
|
```
|
||||||
|
|||||||
+6
-2
@@ -6,12 +6,16 @@ use self::ansi_term::Colour::Fixed;
|
|||||||
|
|
||||||
static UNITS: [char; 4] = ['T', 'G', 'M', 'K'];
|
static UNITS: [char; 4] = ['T', 'G', 'M', 'K'];
|
||||||
|
|
||||||
pub fn display(permissions: bool, to_display: &Vec<&Node>) -> () {
|
pub fn draw_it(permissions: bool, heads: &Vec<Node>, to_display: &Vec<&Node>) -> () {
|
||||||
if !permissions {
|
if !permissions {
|
||||||
eprintln!("Did not have permissions for all directories");
|
eprintln!("Did not have permissions for all directories");
|
||||||
}
|
}
|
||||||
|
|
||||||
display_node(to_display[0], &to_display, true, 1, "")
|
for d in to_display {
|
||||||
|
if heads.contains(d) {
|
||||||
|
display_node(d, &to_display, true, 1, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_node<S: Into<String>>(
|
fn display_node<S: Into<String>>(
|
||||||
|
|||||||
+4
-4
@@ -4,7 +4,7 @@ extern crate dust;
|
|||||||
|
|
||||||
use clap::{App, AppSettings, Arg};
|
use clap::{App, AppSettings, Arg};
|
||||||
use utils::{find_big_ones, get_dir_tree};
|
use utils::{find_big_ones, get_dir_tree};
|
||||||
use self::display::*;
|
use self::display::draw_it;
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
mod display;
|
mod display;
|
||||||
@@ -38,7 +38,7 @@ fn main() {
|
|||||||
let number_of_lines = value_t!(options.value_of("number_of_lines"), usize).unwrap();
|
let number_of_lines = value_t!(options.value_of("number_of_lines"), usize).unwrap();
|
||||||
let use_apparent_size = options.is_present("use_apparent_size");
|
let use_apparent_size = options.is_present("use_apparent_size");
|
||||||
|
|
||||||
let (permissions, results) = get_dir_tree(&filenames, use_apparent_size);
|
let (permissions, node_per_top_level_dir) = get_dir_tree(&filenames, use_apparent_size);
|
||||||
let slice_it = find_big_ones(&results, number_of_lines);
|
let slice_it = find_big_ones(&node_per_top_level_dir, number_of_lines);
|
||||||
display(permissions, &slice_it);
|
draw_it(permissions, &node_per_top_level_dir, &slice_it);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user