mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-08 14:56:12 +02:00
Bump clap to v4.0
This commit is contained in:
parent
df7136837a
commit
e4dfb96b41
|
@ -94,26 +94,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.21"
|
||||
version = "4.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7"
|
||||
checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.2.18"
|
||||
version = "4.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
||||
checksum = "92289ffc6fb4a85d85c246ddb874c05a87a2e540fb6ad52f7ca07c8c1e1840b1"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
|
@ -124,9 +122,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
@ -246,12 +244,6 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
|
@ -273,16 +265,6 @@ version = "0.4.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
|
@ -294,9 +276,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.132"
|
||||
version = "0.2.133"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
|
||||
checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
|
||||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
|
@ -494,12 +476,6 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
|
|
|
@ -16,7 +16,7 @@ pure = ["blake3/pure"]
|
|||
[dependencies]
|
||||
anyhow = "1.0.25"
|
||||
blake3 = { version = "1", path = "..", features = ["rayon"] }
|
||||
clap = { version = "3.2.21", features = ["derive"] }
|
||||
clap = { version = "4.0.8", features = ["derive"] }
|
||||
hex = "0.4.0"
|
||||
memmap2 = "0.5.3"
|
||||
rayon = "1.2.1"
|
||||
|
|
|
@ -5,37 +5,34 @@ A command line utility for calculating
|
|||
Coreutils tools like `b2sum` or `md5sum`.
|
||||
|
||||
```
|
||||
b3sum 1.3.1
|
||||
Usage: b3sum [OPTIONS] [FILE]...
|
||||
|
||||
USAGE:
|
||||
b3sum [OPTIONS] [FILE]...
|
||||
Arguments:
|
||||
[FILE]... Files to hash, or checkfiles to check. When no file is given,
|
||||
or when - is given, read standard input.
|
||||
|
||||
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.
|
||||
--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
|
||||
Options:
|
||||
-l, --length <LEN> The number of output bytes, prior to hex
|
||||
encoding [default: 32]
|
||||
--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.
|
||||
--keyed Uses the keyed mode. The secret key is read from standard
|
||||
input, and it must be exactly 32 raw bytes.
|
||||
--derive-key <CONTEXT> Uses the key derivation mode, with the given
|
||||
context string. Cannot be used with --keyed.
|
||||
--no-mmap Disables memory mapping. Currently this also disables
|
||||
multithreading.
|
||||
--no-names Omits filenames in the output
|
||||
--raw Writes raw output bytes to stdout, rather than hex.
|
||||
--no-names is implied. In this case, only a single
|
||||
input is allowed.
|
||||
-c, --check Reads BLAKE3 sums from the [FILE]s and checks them
|
||||
--quiet Skips printing OK for each successfully verified file.
|
||||
Must be used with --check.
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
```
|
||||
|
||||
See also [this document about how the `--check` flag
|
||||
|
|
|
@ -12,29 +12,29 @@ mod unit_tests;
|
|||
|
||||
const NAME: &str = "b3sum";
|
||||
|
||||
const DERIVE_KEY_ARG: &str = "derive-key";
|
||||
const DERIVE_KEY_ARG: &str = "derive_key";
|
||||
const KEYED_ARG: &str = "keyed";
|
||||
const LENGTH_ARG: &str = "length";
|
||||
const NO_NAMES_ARG: &str = "no-names";
|
||||
const NO_NAMES_ARG: &str = "no_names";
|
||||
const RAW_ARG: &str = "raw";
|
||||
const CHECK_ARG: &str = "check";
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(version)]
|
||||
#[command(version)]
|
||||
struct Inner {
|
||||
/// Files to hash, or checkfiles to check. When no file is given,
|
||||
/// or when - is given, read standard input.
|
||||
#[clap(value_parser, verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment)]
|
||||
file: Vec<PathBuf>,
|
||||
|
||||
/// The number of output bytes, prior to hex
|
||||
/// encoding
|
||||
#[clap(
|
||||
long,
|
||||
#[arg(
|
||||
verbatim_doc_comment,
|
||||
short,
|
||||
value_name("LEN"),
|
||||
long,
|
||||
default_value_t = blake3::OUT_LEN as u64,
|
||||
verbatim_doc_comment
|
||||
value_name("LEN")
|
||||
)]
|
||||
length: u64,
|
||||
|
||||
|
@ -42,43 +42,43 @@ struct Inner {
|
|||
/// 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.
|
||||
#[clap(long, value_name("NUM"), verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment, long, value_name("NUM"))]
|
||||
num_threads: Option<usize>,
|
||||
|
||||
/// Uses the keyed mode. The secret key is read from standard
|
||||
/// input, and it must be exactly 32 raw bytes.
|
||||
#[clap(long, requires("file"), verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment, long, requires("file"))]
|
||||
keyed: bool,
|
||||
|
||||
/// Uses the key derivation mode, with the given
|
||||
/// context string. Cannot be used with --keyed.
|
||||
#[clap(
|
||||
#[arg(
|
||||
verbatim_doc_comment,
|
||||
long,
|
||||
conflicts_with(KEYED_ARG),
|
||||
value_name("CONTEXT"),
|
||||
verbatim_doc_comment
|
||||
conflicts_with(KEYED_ARG)
|
||||
)]
|
||||
derive_key: Option<String>,
|
||||
|
||||
/// Disables memory mapping. Currently this also disables
|
||||
/// multithreading.
|
||||
#[clap(long, verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment, long)]
|
||||
no_mmap: bool,
|
||||
|
||||
/// Omits filenames in the output
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
no_names: bool,
|
||||
|
||||
/// Writes raw output bytes to stdout, rather than hex.
|
||||
/// --no-names is implied. In this case, only a single
|
||||
/// input is allowed.
|
||||
#[clap(long, verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment, long)]
|
||||
raw: bool,
|
||||
|
||||
/// Reads BLAKE3 sums from the [FILE]s and checks them
|
||||
#[clap(
|
||||
long,
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
conflicts_with(DERIVE_KEY_ARG),
|
||||
conflicts_with(KEYED_ARG),
|
||||
conflicts_with(LENGTH_ARG),
|
||||
|
@ -89,7 +89,7 @@ struct Inner {
|
|||
|
||||
/// Skips printing OK for each successfully verified file.
|
||||
/// Must be used with --check.
|
||||
#[clap(long, requires(CHECK_ARG), verbatim_doc_comment)]
|
||||
#[arg(verbatim_doc_comment, long, requires(CHECK_ARG))]
|
||||
quiet: bool,
|
||||
}
|
||||
|
||||
|
@ -594,3 +594,13 @@ fn main() -> Result<()> {
|
|||
std::process::exit(if some_file_failed { 1 } else { 0 });
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use clap::CommandFactory;
|
||||
|
||||
#[test]
|
||||
fn test_args() {
|
||||
crate::Inner::command().debug_assert();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue