diff --git a/Cargo.lock b/Cargo.lock index b05747a..240f522 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,15 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -85,18 +76,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.4" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826bf7bc84f9435630275cb8e802a4a0ec792b615969934bd16d42ffed10f207" +checksum = "5177fac1ab67102d8989464efd043c6ff44191b1557ec1ddd489b4f7e1447e77" dependencies = [ - "ansi_term 0.11.0", "atty", "bitflags", + "indexmap", + "lazy_static", + "os_str_bytes", "strsim", - "term_size", + "termcolor", "textwrap", - "unicode-width", - "vec_map", ] [[package]] @@ -159,7 +150,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" name = "du-dust" version = "0.7.5" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "assert_cmd", "clap", "lscolors", @@ -188,6 +179,12 @@ dependencies = [ "instant", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -197,6 +194,16 @@ dependencies = [ "libc", ] +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.12" @@ -233,7 +240,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b894c45c9da468621cdd615a5a79ee5e5523dd4f75c76ebc03d458940c16e" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", ] [[package]] @@ -261,6 +268,15 @@ dependencies = [ "libc", ] +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] + [[package]] name = "predicates" version = "2.1.1" @@ -372,9 +388,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "tempfile" @@ -391,13 +407,12 @@ dependencies = [ ] [[package]] -name = "term_size" -version = "0.3.2" +name = "termcolor" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ - "libc", - "winapi", + "winapi-util", ] [[package]] @@ -418,13 +433,9 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] name = "textwrap" -version = "0.11.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "term_size", - "unicode-width", -] +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" [[package]] name = "thousands" @@ -438,12 +449,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 157236a..b71edf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ path = "src/main.rs" [dependencies] ansi_term = "0.12" -clap = { version = "=2.33", features = ["wrap_help"] } +clap = { version = "=3", features=["cargo"] } lscolors = "0.7" terminal_size = "0.1" unicode-width = "0.1" diff --git a/src/main.rs b/src/main.rs index e0e7c15..6af4bf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#[macro_use] extern crate clap; extern crate rayon; extern crate regex; @@ -8,10 +7,9 @@ use std::collections::HashSet; use std::process; use self::display::draw_it; -use clap::Values; -use clap::{App, AppSettings, Arg}; -use dir_walker::walk_it; -use dir_walker::WalkData; +use clap::{crate_version, Arg}; +use clap::{Command, Values}; +use dir_walker::{walk_it, WalkData}; use filter::{get_all_file_types, get_biggest, get_by_depth}; use regex::Regex; use std::cmp::max; @@ -104,125 +102,125 @@ fn main() { let default_height = get_height_of_terminal(); let def_num_str = default_height.to_string(); - let options = App::new("Dust") + let options = Command::new("Dust") .about("Like du but more intuitive") .version(crate_version!()) - .setting(AppSettings::TrailingVarArg) + .trailing_var_arg(true) .arg( - Arg::with_name("depth") - .short("d") + Arg::new("depth") + .short('d') .long("depth") .help("Depth to show") .takes_value(true) .conflicts_with("number_of_lines"), ) .arg( - Arg::with_name("number_of_lines") - .short("n") + Arg::new("number_of_lines") + .short('n') .long("number-of-lines") .help("Number of lines of output to show. (Default is terminal_height - 10)") .takes_value(true) .default_value(def_num_str.as_ref()), ) .arg( - Arg::with_name("display_full_paths") - .short("p") + Arg::new("display_full_paths") + .short('p') .long("full-paths") .help("Subdirectories will not have their path shortened"), ) .arg( - Arg::with_name("ignore_directory") - .short("X") + Arg::new("ignore_directory") + .short('X') .long("ignore-directory") .takes_value(true) .number_of_values(1) - .multiple(true) + .multiple_occurrences(true) .help("Exclude any file or directory with this name"), ) .arg( - Arg::with_name("limit_filesystem") - .short("x") + Arg::new("limit_filesystem") + .short('x') .long("limit-filesystem") .help("Only count the files and directories on the same filesystem as the supplied directory"), ) .arg( - Arg::with_name("display_apparent_size") - .short("s") + Arg::new("display_apparent_size") + .short('s') .long("apparent-size") .help("Use file length instead of blocks"), ) .arg( - Arg::with_name("reverse") - .short("r") + Arg::new("reverse") + .short('r') .long("reverse") .help("Print tree upside down (biggest highest)"), ) .arg( - Arg::with_name("no_colors") - .short("c") + Arg::new("no_colors") + .short('c') .long("no-colors") .help("No colors will be printed (Useful for commands like: watch)"), ) .arg( - Arg::with_name("no_bars") - .short("b") + Arg::new("no_bars") + .short('b') .long("no-percent-bars") .help("No percent bars or percentages will be displayed"), ) .arg( - Arg::with_name("by_filecount") - .short("f") + Arg::new("by_filecount") + .short('f') .long("filecount") .help("Directory 'size' is number of child files/dirs not disk size"), ) .arg( - Arg::with_name("ignore_hidden") - .short("i") // Do not use 'h' this is used by 'help' + Arg::new("ignore_hidden") + .short('i') // Do not use 'h' this is used by 'help' .long("ignore_hidden") .help("Do not display hidden files"), ) .arg( - Arg::with_name("invert_filter") - .short("v") + Arg::new("invert_filter") + .short('v') .long("invert-filter") .takes_value(true) .number_of_values(1) - .multiple(true) + .multiple_occurrences(true) .conflicts_with("filter") .conflicts_with("types") .conflicts_with("depth") .help("Exclude files matching this regex. To ignore png files type: -v \"\\.png$\" "), ) .arg( - Arg::with_name("filter") - .short("e") + Arg::new("filter") + .short('e') .long("filter") .takes_value(true) .number_of_values(1) - .multiple(true) + .multiple_occurrences(true) .conflicts_with("types") .conflicts_with("depth") .help("Only include files matching this regex. For png files type: -e \"\\.png$\" "), ) .arg( - Arg::with_name("types") - .short("t") + Arg::new("types") + .short('t') .long("file_types") .conflicts_with("depth") .help("show only these file types"), ) .arg( - Arg::with_name("width") - .short("w") + Arg::new("width") + .short('w') .long("terminal_width") .takes_value(true) .number_of_values(1) .help("Specify width of output overriding the auto detection of terminal width"), ) - .arg(Arg::with_name("inputs").multiple(true).default_value(".")) + .arg(Arg::new("inputs").multiple_occurrences(true).default_value(".")) .arg( - Arg::with_name("iso") - .short("H") + Arg::new("iso") + .short('H') .long("si") .help("print sizes in powers of 1000 (e.g., 1.1G)") ) @@ -238,7 +236,7 @@ fn main() { let filter_regexs = get_regex_value(options.values_of("filter")); let invert_filter_regexs = get_regex_value(options.values_of("invert_filter")); - let number_of_lines = match value_t!(options.value_of("number_of_lines"), usize) { + let number_of_lines = match options.value_of_t("number_of_lines") { Ok(v) => v, Err(_) => { eprintln!("Ignoring bad value for number_of_lines"); @@ -246,7 +244,7 @@ fn main() { } }; - let terminal_width = match value_t!(options.value_of("width"), usize) { + let terminal_width = match options.value_of_t("width") { Ok(v) => v, Err(_) => get_width_of_terminal(), };