From bc08ea48f7f29c35e73d3dbf0aca23d85877a12f Mon Sep 17 00:00:00 2001 From: Gabriel de Perthuis Date: Fri, 4 Nov 2022 10:52:02 +0100 Subject: [PATCH] Upgrade to clap 3 with minimal changes This removes the last cargo audit override (for the unmaintained ansi_term). Don't mark options as required when they have default values: see . --- Cargo.lock | 75 +++++++++++++++---------------- crates/arti-bench/Cargo.toml | 2 +- crates/arti-bench/src/main.rs | 19 +++----- crates/arti-testing/Cargo.toml | 2 +- crates/arti-testing/src/config.rs | 12 +++-- crates/arti/Cargo.toml | 2 +- crates/arti/src/lib.rs | 12 ++--- maint/cargo_audit | 10 ++--- 8 files changed, 61 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54a6d470b3..2c557ceb74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,15 +49,6 @@ dependencies = [ "memchr", ] -[[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.66" @@ -646,17 +637,26 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ - "ansi_term", "atty", "bitflags", - "strsim 0.8.0", + "clap_lex", + "indexmap", + "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -861,7 +861,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -875,7 +875,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -1628,6 +1628,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inotify" version = "0.9.6" @@ -2171,6 +2181,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" + [[package]] name = "overload" version = "0.1.1" @@ -3129,12 +3145,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -3228,12 +3238,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.11.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" @@ -4224,12 +4231,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -4291,12 +4292,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" diff --git a/crates/arti-bench/Cargo.toml b/crates/arti-bench/Cargo.toml index c841973e76..faedd6ad74 100644 --- a/crates/arti-bench/Cargo.toml +++ b/crates/arti-bench/Cargo.toml @@ -15,7 +15,7 @@ repository = "https://gitlab.torproject.org/tpo/core/arti.git/" anyhow = "1.0.23" arti = { path = "../arti", version = "1.0.1" } arti-client = { package = "arti-client", path = "../arti-client", version = "0.7.0" } -clap = "2.33.0" +clap = "3" float-ord = "0.3" fs-mistrust = { path = "../fs-mistrust", version = "0.5.0" } futures = "0.3.14" diff --git a/crates/arti-bench/src/main.rs b/crates/arti-bench/src/main.rs index ec886494c1..a4150a73f4 100644 --- a/crates/arti-bench/src/main.rs +++ b/crates/arti-bench/src/main.rs @@ -287,7 +287,7 @@ fn main() -> Result<()> { .about("A simple benchmarking utility for Arti.") .arg( Arg::with_name("arti-config") - .short("c") + .short('c') .long("arti-config") .takes_value(true) .required(true) @@ -298,58 +298,53 @@ fn main() -> Result<()> { ) .arg( Arg::with_name("num-samples") - .short("s") + .short('s') .long("num-samples") .takes_value(true) - .required(true) .value_name("COUNT") .default_value("3") .help("How many samples to take per benchmark run.") ) .arg( Arg::with_name("num-streams") - .short("p") + .short('p') .long("streams") .aliases(&["num-parallel"]) .takes_value(true) - .required(true) .value_name("COUNT") .default_value("3") .help("How many simultaneous streams per circuit.") ) .arg( Arg::with_name("num-circuits") - .short("C") + .short('C') .long("num-circuits") .takes_value(true) - .required(false) .value_name("COUNT") .default_value("1") .help("How many simultaneous circuits per run.") ) .arg( Arg::with_name("output") - .short("o") + .short('o') .takes_value(true) .value_name("/path/to/output.json") .help("A path to write benchmark results to, in JSON format.") ) .arg( Arg::with_name("download-bytes") - .short("d") + .short('d') .long("download-bytes") .takes_value(true) - .required(true) .value_name("SIZE") .default_value("10485760") .help("How much fake payload data to generate for the download benchmark."), ) .arg( Arg::with_name("upload-bytes") - .short("u") + .short('u') .long("upload-bytes") .takes_value(true) - .required(true) .value_name("SIZE") .default_value("10485760") .help("How much fake payload data to generate for the upload benchmark."), diff --git a/crates/arti-testing/Cargo.toml b/crates/arti-testing/Cargo.toml index 15f70bd85c..8606e2d65e 100644 --- a/crates/arti-testing/Cargo.toml +++ b/crates/arti-testing/Cargo.toml @@ -22,7 +22,7 @@ arti-client = { package = "arti-client", path = "../arti-client", version = "0.7 ] } async-trait = "0.1.2" cfg-if = "1.0.0" -clap = "2.33.0" +clap = "3" config = { version = "0.13", default-features = false } futures = "0.3.14" pin-project = "1" diff --git a/crates/arti-testing/src/config.rs b/crates/arti-testing/src/config.rs index 18632030cb..95773b7bf9 100644 --- a/crates/arti-testing/src/config.rs +++ b/crates/arti-testing/src/config.rs @@ -28,7 +28,7 @@ pub(crate) fn parse_cmdline() -> Result { .usage("arti-testing [OPTIONS]") .arg( Arg::with_name("config-files") - .short("c") + .short('c') .long("config") .takes_value(true) .value_name("FILE") @@ -37,7 +37,7 @@ pub(crate) fn parse_cmdline() -> Result { ) .arg( Arg::with_name("option") - .short("o") + .short('o') .takes_value(true) .value_name("KEY=VALUE") .multiple(true) @@ -45,7 +45,7 @@ pub(crate) fn parse_cmdline() -> Result { ) .arg( Arg::with_name("log") - .short("l") + .short('l') .long("log") .takes_value(true) .value_name("FILTER") @@ -107,15 +107,13 @@ pub(crate) fn parse_cmdline() -> Result { Arg::with_name("target") .long("target") .takes_value(true) - .value_name("ADDR:PORT") - .required(true), + .value_name("ADDR:PORT"), ) .arg( Arg::with_name("retry") .long("retry") .takes_value(true) - .value_name("DELAY") - .required(false), + .value_name("DELAY"), ), ) .subcommand(SubCommand::with_name("bootstrap").about("Try to bootstrap only")) diff --git a/crates/arti/Cargo.toml b/crates/arti/Cargo.toml index 34e29ff870..2dd5ffccaa 100644 --- a/crates/arti/Cargo.toml +++ b/crates/arti/Cargo.toml @@ -49,7 +49,7 @@ anyhow = "1.0.23" arti-client = { package = "arti-client", path = "../arti-client", version = "0.7.0", default-features = false } async-ctrlc = { version = "1.2.0", optional = true } cfg-if = "1.0.0" -clap = "2.33.0" +clap = "3" config = { version = "0.13", default-features = false, features = ["toml"] } derive_builder = { version = "0.11", package = "derive_builder_fork_arti" } educe = "0.4.6" diff --git a/crates/arti/src/lib.rs b/crates/arti/src/lib.rs index e503d8fbf4..0cc7b9fee6 100644 --- a/crates/arti/src/lib.rs +++ b/crates/arti/src/lib.rs @@ -249,18 +249,18 @@ where .usage("arti [OPTIONS]") .arg( Arg::with_name("config-files") - .short("c") + .short('c') .long("config") .takes_value(true) .value_name("FILE") .multiple(true) // NOTE: don't forget the `global` flag on all arguments declared at this level! .global(true) - .help(&config_file_help), + .help(config_file_help.as_str()), ) .arg( Arg::with_name("option") - .short("o") + .short('o') .takes_value(true) .value_name("KEY=VALUE") .multiple(true) @@ -269,7 +269,7 @@ where ) .arg( Arg::with_name("loglevel") - .short("l") + .short('l') .long("log-level") .global(true) .takes_value(true) @@ -290,14 +290,14 @@ where ) .arg( Arg::with_name("socks-port") - .short("p") + .short('p') .takes_value(true) .value_name("PORT") .help("Port to listen on for SOCKS connections (overrides the port in the config if specified).") ) .arg( Arg::with_name("dns-port") - .short("d") + .short('d') .takes_value(true) .value_name("PORT") .help("Port to listen on for DNS request (overrides the port in the config if specified).") diff --git a/maint/cargo_audit b/maint/cargo_audit index c436c519ed..98eb30eef0 100755 --- a/maint/cargo_audit +++ b/maint/cargo_audit @@ -13,17 +13,17 @@ set -euo pipefail # If you add anything to this section, make sure to add a comment # explaining why it's safe to do so. IGNORE=( - # This is not a vulnerability but an unmaintained warning for `ansi_term`. - # The upstream issue does not offer good alternatives, and anyway we get - # this crate via clap and tracing-*. - # It does not seem at all likely that this is really a problem for us. - --ignore RUSTSEC-2021-0139 ) ${CARGO:-cargo} audit -D warnings "${IGNORE[@]}" OBSOLETE_IGNORE=( + # This is not a vulnerability but an unmaintained warning for `ansi_term`. + # The upstream issue does not offer good alternatives, and anyway we get + # this crate via clap and tracing-*. + # It does not seem at all likely that this is really a problem for us. + --ignore RUSTSEC-2021-0139 # This is not a vulnerability but an unmaintained warn for the # `net2` crate. It was pulled indirectly by `notify` 4.0. # It's fixed in `notify` 5.0.