aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2022-01-07 23:10:59 -0500
committerJack O'Connor <[email protected]>2022-01-07 23:57:15 -0500
commit81c8640410e42662aefbb2f3256ed99cf31db55d (patch)
tree79bb2ceaab74bc87e9073539e78301b633c36a1e
parent7d8c00507142b3716d0f606ab4e169e0936316a6 (diff)
update clap to v3
-rw-r--r--b3sum/Cargo.lock89
-rw-r--r--b3sum/Cargo.toml2
-rw-r--r--b3sum/README.md38
-rw-r--r--b3sum/src/main.rs46
4 files changed, 99 insertions, 76 deletions
diff --git a/b3sum/Cargo.lock b/b3sum/Cargo.lock
index cc6d14e..7e01216 100644
--- a/b3sum/Cargo.lock
+++ b/b3sum/Cargo.lock
@@ -3,15 +3,6 @@
version = 3
[[package]]
-name = "ansi_term"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
-dependencies = [
- "winapi",
-]
-
-[[package]]
name = "anyhow"
version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -103,17 +94,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
-version = "2.34.0"
+version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
+checksum = "f6f34b09b9ee8c7c7b400fe2f8df39cafc9538b03d6ba7f4ae13e4cb90bfbb7d"
dependencies = [
- "ansi_term",
"atty",
"bitflags",
+ "indexmap",
+ "os_str_bytes",
"strsim",
+ "termcolor",
"textwrap",
- "unicode-width",
- "vec_map",
]
[[package]]
@@ -233,6 +224,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -248,6 +245,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
+name = "indexmap"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -260,6 +267,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
+name = "memchr"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
+
+[[package]]
name = "memmap"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -305,6 +318,15 @@ dependencies = [
]
[[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 = "ppv-lite86"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -411,9 +433,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 = "subtle"
@@ -436,31 +458,25 @@ dependencies = [
]
[[package]]
-name = "textwrap"
-version = "0.11.0"
+name = "termcolor"
+version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
- "unicode-width",
+ "winapi-util",
]
[[package]]
-name = "typenum"
-version = "1.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
-
-[[package]]
-name = "unicode-width"
-version = "0.1.9"
+name = "textwrap"
+version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
+checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]]
-name = "vec_map"
-version = "0.8.2"
+name = "typenum"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
[[package]]
name = "version_check"
@@ -500,6 +516,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/b3sum/Cargo.toml b/b3sum/Cargo.toml
index 55f9208..6742e01 100644
--- a/b3sum/Cargo.toml
+++ b/b3sum/Cargo.toml
@@ -16,7 +16,7 @@ pure = ["blake3/pure"]
[dependencies]
anyhow = "1.0.25"
blake3 = { version = "1", path = "..", features = ["rayon"] }
-clap = "2.33.1"
+clap = "3.0.5"
hex = "0.4.0"
memmap = "0.7.0"
rayon = "1.2.1"
diff --git a/b3sum/README.md b/b3sum/README.md
index 77975b4..227e33e 100644
--- a/b3sum/README.md
+++ b/b3sum/README.md
@@ -8,36 +8,34 @@ Coreutils tools like `b2sum` or `md5sum`.
b3sum 1.2.0
USAGE:
- b3sum [FLAGS] [OPTIONS] [FILE]...
-
-FLAGS:
- -c, --check Reads BLAKE3 sums from the [file]s and checks them
- -h, --help Prints help information
- --keyed Uses the keyed mode. The secret key is read from standard
- input, and it must be exactly 32 raw bytes.
- --no-mmap Disables memory mapping. Currently this also disables
- multithreading.
- --no-names Omits filenames in the output
- --quiet Skips printing OK for each successfully verified file.
- Must be used with --check.
- --raw Writes raw output bytes to stdout, rather than hex.
- --no-names is implied. In this case, only a single
- input is allowed.
- -V, --version Prints version information
+ b3sum [OPTIONS] [FILE]...
+
+ARGS:
+ <FILE>... Files to hash, or checkfiles to check. When no file is given,
+ or when - is given, read standard input.
OPTIONS:
+ -c, --check Reads BLAKE3 sums from the [file]s and checks them
--derive-key <CONTEXT> Uses the key derivation mode, with the given
context string. Cannot be used with --keyed.
+ -h, --help Print help information
+ --keyed Uses the keyed mode. The secret key is read from standard
+ input, and it must be exactly 32 raw bytes.
-l, --length <LEN> The number of output bytes, prior to hex
encoding (default 32)
+ --no-mmap Disables memory mapping. Currently this also disables
+ multithreading.
+ --no-names Omits filenames in the output
--num-threads <NUM> The maximum number of threads to use. By
default, this is the number of logical cores.
If this flag is omitted, or if its value is 0,
RAYON_NUM_THREADS is also respected.
-
-ARGS:
- <FILE>... Files to hash, or checkfiles to check. When no file is given,
- or when - is given, read standard input.
+ --quiet Skips printing OK for each successfully verified file.
+ Must be used with --check.
+ --raw Writes raw output bytes to stdout, rather than hex.
+ --no-names is implied. In this case, only a single
+ input is allowed.
+ -V, --version Print version information
```
See also [this document about how the `--check` flag
diff --git a/b3sum/src/main.rs b/b3sum/src/main.rs
index 2a9b737..7b7fd60 100644
--- a/b3sum/src/main.rs
+++ b/b3sum/src/main.rs
@@ -24,7 +24,7 @@ const CHECK_ARG: &str = "check";
const QUIET_ARG: &str = "quiet";
struct Args {
- inner: clap::ArgMatches<'static>,
+ inner: clap::ArgMatches,
file_args: Vec<PathBuf>,
base_hasher: blake3::Hasher,
}
@@ -33,14 +33,19 @@ impl Args {
fn parse() -> Result<Self> {
let inner = App::new(NAME)
.version(env!("CARGO_PKG_VERSION"))
- .arg(Arg::with_name(FILE_ARG).multiple(true).help(
- "Files to hash, or checkfiles to check. When no file is given,\n\
+ .arg(
+ Arg::new(FILE_ARG)
+ .multiple_occurrences(true)
+ .allow_invalid_utf8(true)
+ .help(
+ "Files to hash, or checkfiles to check. When no file is given,\n\
or when - is given, read standard input.",
- ))
+ ),
+ )
.arg(
- Arg::with_name(LENGTH_ARG)
+ Arg::new(LENGTH_ARG)
.long(LENGTH_ARG)
- .short("l")
+ .short('l')
.takes_value(true)
.value_name("LEN")
.help(
@@ -49,7 +54,7 @@ impl Args {
),
)
.arg(
- Arg::with_name(NUM_THREADS_ARG)
+ Arg::new(NUM_THREADS_ARG)
.long(NUM_THREADS_ARG)
.takes_value(true)
.value_name("NUM")
@@ -60,17 +65,12 @@ impl Args {
RAYON_NUM_THREADS is also respected.",
),
)
- .arg(
- Arg::with_name(KEYED_ARG)
- .long(KEYED_ARG)
- .requires(FILE_ARG)
- .help(
- "Uses the keyed mode. The secret key is read from standard\n\
+ .arg(Arg::new(KEYED_ARG).long(KEYED_ARG).requires(FILE_ARG).help(
+ "Uses the keyed mode. The secret key is read from standard\n\
input, and it must be exactly 32 raw bytes.",
- ),
- )
+ ))
.arg(
- Arg::with_name(DERIVE_KEY_ARG)
+ Arg::new(DERIVE_KEY_ARG)
.long(DERIVE_KEY_ARG)
.conflicts_with(KEYED_ARG)
.takes_value(true)
@@ -80,33 +80,33 @@ impl Args {
context string. Cannot be used with --keyed.",
),
)
- .arg(Arg::with_name(NO_MMAP_ARG).long(NO_MMAP_ARG).help(
+ .arg(Arg::new(NO_MMAP_ARG).long(NO_MMAP_ARG).help(
"Disables memory mapping. Currently this also disables\n\
multithreading.",
))
.arg(
- Arg::with_name(NO_NAMES_ARG)
+ Arg::new(NO_NAMES_ARG)
.long(NO_NAMES_ARG)
.help("Omits filenames in the output"),
)
- .arg(Arg::with_name(RAW_ARG).long(RAW_ARG).help(
+ .arg(Arg::new(RAW_ARG).long(RAW_ARG).help(
"Writes raw output bytes to stdout, rather than hex.\n\
--no-names is implied. In this case, only a single\n\
input is allowed.",
))
.arg(
- Arg::with_name(CHECK_ARG)
+ Arg::new(CHECK_ARG)
.long(CHECK_ARG)
- .short("c")
+ .short('c')
.conflicts_with(DERIVE_KEY_ARG)
.conflicts_with(KEYED_ARG)
.conflicts_with(LENGTH_ARG)
.conflicts_with(RAW_ARG)
.conflicts_with(NO_NAMES_ARG)
- .help("Reads BLAKE3 sums from the [file]s and checks them"),
+ .help("Reads BLAKE3 sums from the [FILE]s and checks them"),
)
.arg(
- Arg::with_name(QUIET_ARG)
+ Arg::new(QUIET_ARG)
.long(QUIET_ARG)
.requires(CHECK_ARG)
.help(