Update library: Clap

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