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
Provenance
- Commit
10ba34f- Tree
9c22c7e- Author
Thayne McCombs <astrothayne@gmail.com>- Committer
Thayne McCombs <astrothayne@gmail.com>- Parent
686318c
5 files changed+71 added−19 removed
modified:src/exec/mod.rs+6 added-4 removed
37 unmodified lines38 commands: Vec<CommandTemplate>,39 }40 41 impl 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 lines53 .collect::<Result<_>>()?,54 })55 }56 56- 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 linesmodified:src/cli.rs+2 added-2 removed
736 unmodified lines737 738 impl 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 linesmodified:tests/tests.rs+12 added-4 removed
1706 unmodified lines1707 "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 );1714 1715 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 );1724 1725 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 );1732 1733 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 );1742 1743 te.assert_failure_with_error(&["a.foo", "--exec-batch", "bash", "-c", "exit 1"], "");710 unmodified linesmodified:Cargo.lock+50 added-8 removed
99 unmodified lines100 ]101 102 [[package]]103 name = "clap"104-version = "4.0.22"104+version = "4.1.1"105 source = "registry+https://github.com/rust-lang/crates.io-index"106-checksum = "91b9970d7505127a162fdaa9b96428d28a479ba78c9ec7550a63a5d9863db682"106+checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2"107 dependencies = [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 lines125 ]126 127 [[package]]128 name = "clap_derive"129-version = "4.0.21"129+version = "4.1.0"130 source = "registry+https://github.com/rust-lang/crates.io-index"131-checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"131+checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8"132 dependencies = [133 "heck",134 "proc-macro-error",135 "proc-macro2",337 unmodified lines473 source = "registry+https://github.com/rust-lang/crates.io-index"474 checksum = "e6e481ccbe3dea62107216d0d1138bb8ad8e5e5c43009a098bd1990272c497b0"475 476 [[package]]477+name = "io-lifetimes"478+version = "1.0.4"479+source = "registry+https://github.com/rust-lang/crates.io-index"480+checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"481+dependencies = [482+ "libc",483+ "windows-sys 0.42.0",484+]485+486+[[package]]487+name = "is-terminal"488+version = "0.4.2"489+source = "registry+https://github.com/rust-lang/crates.io-index"490+checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"491+dependencies = [492+ "hermit-abi 0.2.6",493+ "io-lifetimes 1.0.4",494+ "rustix 0.36.6",495+ "windows-sys 0.42.0",496+]497+498+[[package]]499 name = "jemalloc-sys"500 version = "0.5.2+5.3.0-patched"501 source = "registry+https://github.com/rust-lang/crates.io-index"502 checksum = "134163979b6eed9564c98637b710b40979939ba351f59952708234ea11b5f3f8"49 unmodified lines552 source = "registry+https://github.com/rust-lang/crates.io-index"553 checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"554 555 [[package]]556+name = "linux-raw-sys"557+version = "0.1.4"558+source = "registry+https://github.com/rust-lang/crates.io-index"559+checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"560+561+[[package]]562 name = "log"563 version = "0.4.17"564 source = "registry+https://github.com/rust-lang/crates.io-index"565 checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"200 unmodified lines766 checksum = "985947f9b6423159c4726323f373be0a21bdb514c5af06a849cb3d2dce2d01e8"767 dependencies = [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 ]775 776 [[package]]777+name = "rustix"778+version = "0.36.6"779+source = "registry+https://github.com/rust-lang/crates.io-index"780+checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549"781+dependencies = [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+]789+790+[[package]]791 name = "same-file"792 version = "1.0.6"793 source = "registry+https://github.com/rust-lang/crates.io-index"794 checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"52 unmodified lines847 version = "0.2.1"848 source = "registry+https://github.com/rust-lang/crates.io-index"849 checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1"850 dependencies = [809- "rustix",851+ "rustix 0.35.12",852 "windows-sys 0.36.1",853 ]854 855 [[package]]279 unmodified linesmodified:Cargo.toml+1 added-1 removed
50 unmodified lines5152535455555657585936 unmodified lines50 unmodified linesclap_complete = {version = "4.0.6", optional = true}faccess = "0.2.4"
[dependencies.clap]version = "4.0.22"version = "4.1.1"features = ["suggestions", "color", "wrap_help", "cargo", "unstable-grouped", "derive"]
[dependencies.chrono]version = "0.4.23"36 unmodified lines