From 15a867636f5aa60dfaf2497082a15a538eec455f Mon Sep 17 00:00:00 2001 From: QuarticCat Date: Sat, 5 Jun 2021 20:39:59 +0800 Subject: [PATCH 1/2] Add wrap_help feature to clap --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 11 +++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7205b51..b6666836 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,6 +94,7 @@ dependencies = [ "atty", "bitflags", "strsim", + "term_size", "textwrap", "unicode-width", "vec_map", @@ -419,6 +420,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "term_size" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "terminal_size" version = "0.1.15" @@ -435,6 +446,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ + "term_size", "unicode-width", ] diff --git a/Cargo.toml b/Cargo.toml index 270c0979..5ce75e8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ categories = ["command-line-utilities"] license = "Apache-2.0" [badges] -travis-ci = {repository = "https://travis-ci.org/bootandy/dust"} +travis-ci = { repository = "https://travis-ci.org/bootandy/dust" } [[bin]] name = "dust" @@ -22,14 +22,14 @@ path = "src/main.rs" [dependencies] ansi_term = "0.12" -clap = "=2.33" +clap = { version = "=2.33", features = ["wrap_help"] } lscolors = "0.7" num_cpus = "1" terminal_size = "0.1" unicode-width = "0.1" -ignore="0.4" +ignore = "0.4" crossbeam-channel = "0.4" -walkdir="2.3" +walkdir = "2.3" thousands = "0.2" stfu8 = "0.2" @@ -37,10 +37,9 @@ stfu8 = "0.2" winapi-util = "0.1" [dev-dependencies] -assert_cmd ="1" +assert_cmd = "1" tempfile = "=3" - [[test]] name = "integration" path = "tests/tests.rs" From 551c5d3bfa279da206805d31c95d56ec1bf425d1 Mon Sep 17 00:00:00 2001 From: QuarticCat Date: Sat, 5 Jun 2021 21:09:31 +0800 Subject: [PATCH 2/2] Simplify conflict implementation --- src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1a6d31ef..ec248340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,8 @@ fn main() { .short("d") .long("depth") .help("Depth to show") - .takes_value(true), + .takes_value(true) + .conflicts_with("number_of_lines"), ) .arg( Arg::with_name("number_of_lines") @@ -150,7 +151,6 @@ fn main() { .number_of_values(1) .help("Specify width of output overriding the auto detection of terminal width"), ) - .arg(Arg::with_name("inputs").multiple(true)) .get_matches(); @@ -181,10 +181,6 @@ fn main() { .map_err(|_| eprintln!("Ignoring bad value for depth")) .ok() }); - if options.is_present("depth") && number_of_lines != default_height { - eprintln!("Use either -n or -d. Not both"); - return; - } let no_colors = init_color(options.is_present("no_colors")); let use_apparent_size = options.is_present("display_apparent_size");