Skip to content

Commit 1f02a67

Browse files
authored
build(deps): replace structopt with clapv4 (#3182)
1 parent ce2ab1b commit 1f02a67

21 files changed

Lines changed: 206 additions & 175 deletions

File tree

.github/config/cargo-deny.toml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
[advisories]
22
yanked = "deny"
3-
ignore = [
4-
# `atty` is a dependency of `structopt` and only used in s2n-quic-qns and s2n-quic-sim
5-
# https://github.com/aws/s2n-quic/issues/2324
6-
"RUSTSEC-2021-0145",
7-
# `atty` is a dependency of `structopt` and only used in s2n-quic-qns and s2n-quic-sim
8-
# https://github.com/aws/s2n-quic/issues/2324
9-
"RUSTSEC-2024-0375",
10-
# ` proc-macro-error` is a dependency of `structopt` and only used in s2n-quic-qns and s2n-quic-sim
11-
# https://github.com/aws/s2n-quic/issues/2324
12-
"RUSTSEC-2024-0370",
13-
# `ansi_term` is a dependency of `structopt` and only used in s2n-quic-qns and s2n-quic-sim
14-
# https://github.com/aws/s2n-quic/issues/2324
15-
"RUSTSEC-2021-0139",
16-
# `structopt` is in maintenance mode and only used in s2n-quic-qns and s2n-quic-sim
17-
# https://github.com/aws/s2n-quic/issues/2324
18-
"RUSTSEC-2022-0104"
19-
]
3+
ignore = []
204

215
[bans]
226
multiple-versions = "deny"

quic/s2n-quic-qns/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rand = "0.10"
2626
s2n-codec = { path = "../../common/s2n-codec" }
2727
s2n-quic-core = { path = "../s2n-quic-core", features = ["testing"] }
2828
s2n-quic-h3 = { path = "../s2n-quic-h3" }
29-
structopt = "0.3"
29+
clap = { version = "4", features = ["derive", "env"] }
3030
tokio = { version = "1", features = ["full"] }
3131
tracing = "0.1"
3232
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

quic/s2n-quic-qns/src/client/interop.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,64 @@ use crate::{
88
interop::Testcase,
99
task, tls, Result,
1010
};
11+
use clap::{builder::TypedValueParser as _, Args};
1112
use core::time::Duration;
1213
use s2n_quic::{client::Connect, provider::event, Client};
1314
use std::{
1415
collections::{hash_map::Entry, HashMap},
1516
path::PathBuf,
1617
sync::Arc,
1718
};
18-
use structopt::StructOpt;
1919
use tokio::net::lookup_host;
2020
use url::{Host, Url};
2121

22-
#[derive(Debug, StructOpt)]
22+
#[derive(Debug, Args)]
2323
pub struct Interop {
24-
#[structopt(short, long)]
24+
#[clap(short, long)]
2525
ip: Option<std::net::IpAddr>,
2626

27-
#[structopt(short, long, default_value = "443")]
27+
#[clap(short, long, default_value = "443")]
2828
port: u16,
2929

30-
#[structopt(long, default_value = "hq-interop")]
30+
#[clap(long, default_value = "hq-interop")]
3131
application_protocols: Vec<String>,
3232

33-
#[structopt(long)]
33+
#[clap(long)]
3434
download_dir: Option<PathBuf>,
3535

36-
#[structopt(long, parse(try_from_str = parse_duration))]
36+
#[clap(long, value_parser = parse_duration)]
3737
keep_alive: Option<Duration>,
3838

39-
#[structopt(long, env = "TESTCASE", possible_values = &Testcase::supported(is_supported_testcase))]
39+
#[clap(
40+
long,
41+
env = "TESTCASE",
42+
value_parser = clap::builder::PossibleValuesParser::new(Testcase::supported(is_supported_testcase))
43+
.map(|s| s.parse::<Testcase>().unwrap()),
44+
)]
4045
testcase: Option<Testcase>,
4146

42-
#[structopt(long, default_value = "20")]
47+
#[clap(long, default_value = "20")]
4348
concurrency: u64,
4449

45-
#[structopt(min_values = 1, required = true)]
50+
#[clap(required = true)]
4651
requests: Vec<Url>,
4752

48-
#[structopt(flatten)]
53+
#[clap(flatten)]
4954
limits: crate::limits::Limits,
5055

51-
#[structopt(flatten)]
56+
#[clap(flatten)]
5257
io: crate::io::Client,
5358

54-
#[structopt(flatten)]
59+
#[clap(flatten)]
5560
tls: tls::Client,
5661

57-
#[structopt(flatten)]
62+
#[clap(flatten)]
5863
runtime: crate::runtime::Runtime,
5964

60-
#[structopt(flatten)]
65+
#[clap(flatten)]
6166
congestion_controller: crate::congestion_control::CongestionControl,
6267

63-
#[structopt(flatten)]
68+
#[clap(flatten)]
6469
intercept: Intercept,
6570
}
6671

quic/s2n-quic-qns/src/client/perf.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,62 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::{client, intercept::Intercept, perf, task, tls, Result};
5+
use clap::Args;
56
use s2n_quic::{client::Connect, provider::event, Client, Connection};
6-
use structopt::StructOpt;
77

8-
#[derive(Debug, StructOpt)]
8+
#[derive(Debug, Args)]
99
pub struct Perf {
10-
#[structopt(short, long, default_value = "127.0.0.1")]
10+
#[clap(short, long, default_value = "127.0.0.1")]
1111
ip: std::net::IpAddr,
1212

13-
#[structopt(short, long, default_value = "443")]
13+
#[clap(short, long, default_value = "443")]
1414
port: u16,
1515

16-
#[structopt(short, long)]
16+
#[clap(short, long)]
1717
server_name: Option<String>,
1818

1919
//= https://tools.ietf.org/id/draft-banks-quic-performance-00#2.1
2020
//# The ALPN used by the QUIC performance protocol is "perf".
21-
#[structopt(long, default_value = "perf")]
21+
#[clap(long, default_value = "perf")]
2222
application_protocols: Vec<String>,
2323

2424
/// The total number of connections to open from the client
25-
#[structopt(long, default_value = "1")]
25+
#[clap(long, default_value = "1")]
2626
connections: usize,
2727

2828
/// Defines the number of concurrent connections to open at any given time
29-
#[structopt(long, default_value = "10")]
29+
#[clap(long, default_value = "10")]
3030
concurrency: u64,
3131

32-
#[structopt(long, default_value)]
32+
#[clap(long, default_value_t)]
3333
send: u64,
3434

35-
#[structopt(long, default_value)]
35+
#[clap(long, default_value_t)]
3636
receive: u64,
3737

38-
#[structopt(long, default_value = "1")]
38+
#[clap(long, default_value = "1")]
3939
streams: u64,
4040

41-
#[structopt(flatten)]
41+
#[clap(flatten)]
4242
limits: crate::limits::Limits,
4343

4444
/// Logs statistics for the endpoint
45-
#[structopt(long)]
45+
#[clap(long)]
4646
stats: bool,
4747

48-
#[structopt(flatten)]
48+
#[clap(flatten)]
4949
io: crate::io::Client,
5050

51-
#[structopt(flatten)]
51+
#[clap(flatten)]
5252
tls: tls::Client,
5353

54-
#[structopt(flatten)]
54+
#[clap(flatten)]
5555
runtime: crate::runtime::Runtime,
5656

57-
#[structopt(flatten)]
57+
#[clap(flatten)]
5858
congestion_controller: crate::congestion_control::CongestionControl,
5959

60-
#[structopt(flatten)]
60+
#[clap(flatten)]
6161
intercept: Intercept,
6262
}
6363

quic/s2n-quic-qns/src/congestion_control.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use clap::{builder::TypedValueParser as _, Args};
45
use core::str::FromStr;
56
use std::io;
6-
use structopt::StructOpt;
77

8-
#[derive(Debug, StructOpt)]
8+
#[derive(Debug, Args)]
99
pub struct CongestionControl {
1010
/// The congestion controller to use
11-
#[structopt(long = "cc", default_value = "bbr", possible_values = &["cubic","bbr"])]
11+
#[clap(
12+
long = "cc",
13+
default_value = "bbr",
14+
value_parser = clap::builder::PossibleValuesParser::new(["cubic", "bbr"])
15+
.map(|s| s.parse::<CongestionController>().unwrap()),
16+
)]
1217
pub congestion_controller: CongestionController,
1318
}
1419

quic/s2n-quic-qns/src/intercept.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use clap::Args;
45
use lru::LruCache;
56
use rand::Rng as _;
67
use s2n_codec::encoder::scatter;
@@ -13,17 +14,16 @@ use s2n_quic_core::{
1314
},
1415
path::RemoteAddress,
1516
};
16-
use structopt::StructOpt;
1717

18-
#[derive(Debug, StructOpt)]
18+
#[derive(Debug, Args)]
1919
pub struct Intercept {
20-
#[structopt(long)]
20+
#[clap(long)]
2121
havoc_rx: bool,
2222

23-
#[structopt(long)]
23+
#[clap(long)]
2424
havoc_tx: bool,
2525

26-
#[structopt(long)]
26+
#[clap(long)]
2727
havoc_port: bool,
2828
}
2929

quic/s2n-quic-qns/src/io.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::Result;
5+
use clap::Args;
56
use s2n_quic::provider::io;
6-
use structopt::StructOpt;
77

8-
#[derive(Debug, StructOpt)]
8+
#[derive(Debug, Args)]
9+
#[group(skip)]
910
pub struct Server {
10-
#[structopt(short, long, default_value = "::")]
11+
#[clap(short, long, default_value = "::")]
1112
pub ip: std::net::IpAddr,
1213

13-
#[structopt(short, long, default_value = "443")]
14+
#[clap(short, long, default_value = "443")]
1415
pub port: u16,
1516

16-
#[structopt(long)]
17+
#[clap(long)]
1718
pub disable_gso: bool,
1819

19-
#[structopt(long, default_value = "1280")]
20+
#[clap(long, default_value = "1280")]
2021
pub initial_mtu: u16,
2122

22-
#[structopt(long, default_value = "9000")]
23+
#[clap(long, default_value = "9000")]
2324
pub max_mtu: u16,
2425

25-
#[structopt(long)]
26+
#[clap(long)]
2627
pub queue_recv_buffer_size: Option<usize>,
2728

28-
#[structopt(long)]
29+
#[clap(long)]
2930
pub queue_send_buffer_size: Option<usize>,
3031

3132
#[cfg(feature = "xdp")]
32-
#[structopt(flatten)]
33+
#[clap(flatten)]
3334
xdp: crate::xdp::Xdp,
3435
}
3536

@@ -68,28 +69,29 @@ impl Server {
6869
}
6970
}
7071

71-
#[derive(Debug, StructOpt)]
72+
#[derive(Debug, Args)]
73+
#[group(skip)]
7274
pub struct Client {
73-
#[structopt(long)]
75+
#[clap(long)]
7476
pub disable_gso: bool,
7577

76-
#[structopt(long, default_value = "1280")]
78+
#[clap(long, default_value = "1280")]
7779
pub initial_mtu: u16,
7880

79-
#[structopt(long, default_value = "9000")]
81+
#[clap(long, default_value = "9000")]
8082
pub max_mtu: u16,
8183

82-
#[structopt(long)]
84+
#[clap(long)]
8385
pub queue_recv_buffer_size: Option<usize>,
8486

85-
#[structopt(long)]
87+
#[clap(long)]
8688
pub queue_send_buffer_size: Option<usize>,
8789

88-
#[structopt(short, long, default_value = "::")]
90+
#[clap(short, long, default_value = "::")]
8991
pub local_ip: std::net::IpAddr,
9092

9193
#[cfg(feature = "xdp")]
92-
#[structopt(flatten)]
94+
#[clap(flatten)]
9395
xdp: crate::xdp::Xdp,
9496
}
9597

quic/s2n-quic-qns/src/limits.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33

44
use core::time::Duration;
55

6-
#[derive(Debug, structopt::StructOpt)]
6+
#[derive(Debug, clap::Args)]
77
pub struct Limits {
88
/// The maximum bits/sec for each connection
9-
#[structopt(long, default_value = "150")]
9+
#[clap(long, default_value = "150")]
1010
pub max_throughput: u64,
1111

1212
/// The expected RTT in milliseconds
13-
#[structopt(long, default_value = "100")]
13+
#[clap(long, default_value = "100")]
1414
pub expected_rtt: u64,
1515

16-
#[structopt(long)]
16+
#[clap(long)]
1717
pub stream_send_buffer_size: Option<u32>,
1818

1919
/// The maximum time (in seconds) the handshake may take to complete
20-
#[structopt(long, default_value = "300")]
20+
#[clap(long, default_value = "300")]
2121
pub max_handshake_duration: u64,
2222

2323
/// The maximum time (in seconds) a connection will remain open without contact from the peer
24-
#[structopt(long, default_value = "300")]
24+
#[clap(long, default_value = "300")]
2525
pub max_idle_timeout: u64,
2626
}
2727

0 commit comments

Comments
 (0)