Skip to content
Myr

update: Update to clap 4.1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This includes switching to the stable API for getting values grouped by occurrences, and updating tests to match the new error messages.

authored by Thayne McCombs · committed by Thayne McCombs · parent 686318c · Browse files · 5 files+71 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+71 added−19 removed

  • tests:+12 added−4 removed
  • other:+59 added−15 removed

5 files+71 added−19 removed

modified:src/exec/mod.rs+6 added-4 removed
37 unmodified lines
38 commands: Vec<CommandTemplate>,39}4041impl CommandSet {42 pub fn new<I, S>(input: I) -> Result<CommandSet>42 pub fn new<I, T, S>(input: I) -> Result<CommandSet>43 where44 I: IntoIterator<Item = Vec<S>>,44 I: IntoIterator<Item = T>,45 T: IntoIterator<Item = S>,46 S: AsRef<str>,47 {48 Ok(CommandSet {49 mode: ExecutionMode::OneByOne,
3 unmodified lines
53 .collect::<Result<_>>()?,54 })55 }5656 pub fn new_batch<I, S>(input: I) -> Result<CommandSet>57 pub fn new_batch<I, T, S>(input: I) -> Result<CommandSet>58 where58 I: IntoIterator<Item = Vec<S>>,59 I: IntoIterator<Item = T>,60 T: IntoIterator<Item = S>,61 S: AsRef<str>,62 {63 Ok(CommandSet {64 mode: ExecutionMode::Batch,
532 unmodified lines
modified:src/cli.rs+2 added-2 removed
736 unmodified lines
737738impl clap::FromArgMatches for Exec {739 fn from_arg_matches(matches: &ArgMatches) -> clap::error::Result<Self> {740 let command = matches741 .grouped_values_of("exec")741 .get_occurrences::<String>("exec")742 .map(CommandSet::new)743 .or_else(|| {744 matches745 .grouped_values_of("exec_batch")745 .get_occurrences::<String>("exec_batch")746 .map(CommandSet::new_batch)747 })748 .transpose()749 .map_err(|e| clap::Error::raw(ErrorKind::InvalidValue, e))?;
90 unmodified lines
modified:tests/tests.rs+12 added-4 removed
1706 unmodified lines
1707 "error: Only one placeholder allowed for batch commands\n\1708 \n\1709 Usage: fd [OPTIONS] [pattern] [path]...\n\1710 \n\1711 For more information try '--help'\n\1711 For more information, try '--help'.\n\1712 ",1713 );17141715 te.assert_failure_with_error(1716 &["foo", "--exec-batch", "echo", "{/}", ";", "-x", "echo"],1717 "error: The argument '--exec-batch <cmd>...' cannot be used with '--exec <cmd>...'",1717 "error: the argument '--exec-batch <cmd>...' cannot be used with '--exec <cmd>...'\n\1718 \n\1719 Usage: fd --exec-batch <cmd>... <pattern> [path]...\n\1720 \n\1721 For more information, try '--help'.\n\1722 ",1723 );17241725 te.assert_failure_with_error(1726 &["foo", "--exec-batch"],1722 "error: The argument '--exec-batch <cmd>...' requires a value but none was supplied",1727 "error: a value is required for '--exec-batch <cmd>...' but none was supplied\n\1728 \n\1729 For more information, try '--help'.\n\1730 ",1731 );17321733 te.assert_failure_with_error(1734 &["foo", "--exec-batch", "echo {}"],1735 "error: First argument of exec-batch is expected to be a fixed executable\n\1736 \n\1737 Usage: fd [OPTIONS] [pattern] [path]...\n\1738 \n\1731 For more information try '--help'\n\1739 For more information, try '--help'.\n\1740 ",1741 );17421743 te.assert_failure_with_error(&["a.foo", "--exec-batch", "bash", "-c", "exit 1"], "");
710 unmodified lines
modified:Cargo.lock+50 added-8 removed
99 unmodified lines
100]101102[[package]]103name = "clap"104version = "4.0.22"104version = "4.1.1"105source = "registry+https://github.com/rust-lang/crates.io-index"106checksum = "91b9970d7505127a162fdaa9b96428d28a479ba78c9ec7550a63a5d9863db682"106checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2"107dependencies = [108 "atty",108 "bitflags",109 "clap_derive",110 "clap_lex",111 "is-terminal",112 "once_cell",113 "strsim",114 "termcolor",115 "terminal_size",
9 unmodified lines
125]126127[[package]]128name = "clap_derive"129version = "4.0.21"129version = "4.1.0"130source = "registry+https://github.com/rust-lang/crates.io-index"131checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"131checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8"132dependencies = [133 "heck",134 "proc-macro-error",135 "proc-macro2",
337 unmodified lines
473source = "registry+https://github.com/rust-lang/crates.io-index"474checksum = "e6e481ccbe3dea62107216d0d1138bb8ad8e5e5c43009a098bd1990272c497b0"475476[[package]]477name = "io-lifetimes"478version = "1.0.4"479source = "registry+https://github.com/rust-lang/crates.io-index"480checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"481dependencies = [482 "libc",483 "windows-sys 0.42.0",484]485486[[package]]487name = "is-terminal"488version = "0.4.2"489source = "registry+https://github.com/rust-lang/crates.io-index"490checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"491dependencies = [492 "hermit-abi 0.2.6",493 "io-lifetimes 1.0.4",494 "rustix 0.36.6",495 "windows-sys 0.42.0",496]497498[[package]]499name = "jemalloc-sys"500version = "0.5.2+5.3.0-patched"501source = "registry+https://github.com/rust-lang/crates.io-index"502checksum = "134163979b6eed9564c98637b710b40979939ba351f59952708234ea11b5f3f8"
49 unmodified lines
552source = "registry+https://github.com/rust-lang/crates.io-index"553checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"554555[[package]]556name = "linux-raw-sys"557version = "0.1.4"558source = "registry+https://github.com/rust-lang/crates.io-index"559checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"560561[[package]]562name = "log"563version = "0.4.17"564source = "registry+https://github.com/rust-lang/crates.io-index"565checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
200 unmodified lines
766checksum = "985947f9b6423159c4726323f373be0a21bdb514c5af06a849cb3d2dce2d01e8"767dependencies = [768 "bitflags",769 "errno",742 "io-lifetimes",770 "io-lifetimes 0.7.4",771 "libc",744 "linux-raw-sys",772 "linux-raw-sys 0.0.46",773 "windows-sys 0.36.1",774]775776[[package]]777name = "rustix"778version = "0.36.6"779source = "registry+https://github.com/rust-lang/crates.io-index"780checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549"781dependencies = [782 "bitflags",783 "errno",784 "io-lifetimes 1.0.4",785 "libc",786 "linux-raw-sys 0.1.4",787 "windows-sys 0.42.0",788]789790[[package]]791name = "same-file"792version = "1.0.6"793source = "registry+https://github.com/rust-lang/crates.io-index"794checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
52 unmodified lines
847version = "0.2.1"848source = "registry+https://github.com/rust-lang/crates.io-index"849checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1"850dependencies = [809 "rustix",851 "rustix 0.35.12",852 "windows-sys 0.36.1",853]854855[[package]]
279 unmodified lines
modified:Cargo.toml+1 added-1 removed