Skip to content

Commit

Permalink
Upgrade to clap 3 with minimal changes
Browse files Browse the repository at this point in the history
This removes the last cargo audit override (for the unmaintained
ansi_term).

Don't mark options as required when they have default values:
see <clap-rs/clap#3793>.
  • Loading branch information
g2p committed Nov 4, 2022
1 parent 7d079ad commit bc08ea4
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 73 deletions.
75 changes: 35 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/arti-bench/Cargo.toml
Expand Up @@ -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"
Expand Down
19 changes: 7 additions & 12 deletions crates/arti-bench/src/main.rs
Expand Up @@ -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)
Expand All @@ -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."),
Expand Down
2 changes: 1 addition & 1 deletion crates/arti-testing/Cargo.toml
Expand Up @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions crates/arti-testing/src/config.rs
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn parse_cmdline() -> Result<Job> {
.usage("arti-testing <SUBCOMMAND> [OPTIONS]")
.arg(
Arg::with_name("config-files")
.short("c")
.short('c')
.long("config")
.takes_value(true)
.value_name("FILE")
Expand All @@ -37,15 +37,15 @@ pub(crate) fn parse_cmdline() -> Result<Job> {
)
.arg(
Arg::with_name("option")
.short("o")
.short('o')
.takes_value(true)
.value_name("KEY=VALUE")
.multiple(true)
.global(true),
)
.arg(
Arg::with_name("log")
.short("l")
.short('l')
.long("log")
.takes_value(true)
.value_name("FILTER")
Expand Down Expand Up @@ -107,15 +107,13 @@ pub(crate) fn parse_cmdline() -> Result<Job> {
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"))
Expand Down
2 changes: 1 addition & 1 deletion crates/arti/Cargo.toml
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions crates/arti/src/lib.rs
Expand Up @@ -249,18 +249,18 @@ where
.usage("arti <SUBCOMMAND> [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)
Expand All @@ -269,7 +269,7 @@ where
)
.arg(
Arg::with_name("loglevel")
.short("l")
.short('l')
.long("log-level")
.global(true)
.takes_value(true)
Expand All @@ -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).")
Expand Down
10 changes: 5 additions & 5 deletions maint/cargo_audit
Expand Up @@ -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.
Expand Down

0 comments on commit bc08ea4

Please sign in to comment.