refactor(cli): reorganize feature flags and update distribution config
This commit is contained in:
5 files changed
+57
-24
No files matched your search
@@ -52,6 +52,10 @@ only `irtt-rs` and symlink or hardlink applet names such as `irtt-cli`,
|
|||||||
`irtt-tui`, and future server applet names to it. Applet dispatch is based on
|
`irtt-tui`, and future server applet names to it. Applet dispatch is based on
|
||||||
the invoked binary name.
|
the invoked binary name.
|
||||||
|
|
||||||
|
cargo-dist release archives currently bundle all enabled applets for a target.
|
||||||
|
That is separate from space-sensitive package layouts, which may still ship one
|
||||||
|
binary plus applet-name symlinks or hardlinks.
|
||||||
|
|
||||||
## CLI usage
|
## CLI usage
|
||||||
|
|
||||||
Basic test:
|
Basic test:
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ required-features = ["tui"]
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["client", "stats"]
|
default = ["client", "stats"]
|
||||||
client = ["dep:irtt-client", "dep:irtt-proto"]
|
client-runtime = ["dep:irtt-client", "dep:irtt-proto"]
|
||||||
stats = ["client", "dep:irtt-stats"]
|
client = ["client-runtime"]
|
||||||
tui = ["client", "stats", "dep:ratatui", "dep:crossterm"]
|
stats = ["client-runtime", "dep:irtt-stats"]
|
||||||
|
tui = ["client-runtime", "stats", "dep:ratatui", "dep:crossterm"]
|
||||||
|
full = ["client", "stats", "tui"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.6.1", features = ["derive"] }
|
clap = { version = "4.6.1", features = ["derive"] }
|
||||||
|
|||||||
@@ -54,19 +54,24 @@ impl std::ops::Deref for TuiArgs {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::cmd::client::ClientArgs;
|
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct SharedOnlyArgs {
|
||||||
|
#[command(flatten)]
|
||||||
|
common: CommonClientArgs,
|
||||||
|
}
|
||||||
|
|
||||||
fn parse(args: &[&str]) -> Result<TuiArgs, clap::Error> {
|
fn parse(args: &[&str]) -> Result<TuiArgs, clap::Error> {
|
||||||
let mut argv = vec!["irtt-tui"];
|
let mut argv = vec!["irtt-tui"];
|
||||||
argv.extend_from_slice(args);
|
argv.extend_from_slice(args);
|
||||||
TuiArgs::try_parse_from(argv)
|
TuiArgs::try_parse_from(argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_client(args: &[&str]) -> Result<ClientArgs, clap::Error> {
|
fn parse_shared(args: &[&str]) -> Result<SharedOnlyArgs, clap::Error> {
|
||||||
let mut argv = vec!["irtt-cli"];
|
let mut argv = vec!["shared-only"];
|
||||||
argv.extend_from_slice(args);
|
argv.extend_from_slice(args);
|
||||||
ClientArgs::try_parse_from(argv)
|
SharedOnlyArgs::try_parse_from(argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -90,8 +95,29 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn shared_client_options_match_between_stream_and_tui_parsers() {
|
fn shared_client_options_match_tui_config_mapping() {
|
||||||
let shared = [
|
let shared = [
|
||||||
|
"--interval",
|
||||||
|
"250ms",
|
||||||
|
"--length",
|
||||||
|
"128",
|
||||||
|
"--hmac",
|
||||||
|
"secret",
|
||||||
|
"--clock",
|
||||||
|
"monotonic",
|
||||||
|
"--tstamp",
|
||||||
|
"receive",
|
||||||
|
"--stats",
|
||||||
|
"count",
|
||||||
|
"--sfill",
|
||||||
|
"abc",
|
||||||
|
"--dscp",
|
||||||
|
"46",
|
||||||
|
"--ttl",
|
||||||
|
"64",
|
||||||
|
"--loose",
|
||||||
|
];
|
||||||
|
let tui_args = [
|
||||||
"--duration",
|
"--duration",
|
||||||
"30s",
|
"30s",
|
||||||
"--interval",
|
"--interval",
|
||||||
@@ -115,20 +141,21 @@ mod tests {
|
|||||||
"--loose",
|
"--loose",
|
||||||
"127.0.0.1:2112",
|
"127.0.0.1:2112",
|
||||||
];
|
];
|
||||||
let client = parse_client(&shared).unwrap().to_client_config();
|
let tui = parse(&tui_args).unwrap().to_client_config();
|
||||||
let tui = parse(&shared).unwrap().to_client_config();
|
let common = parse_shared(&shared).unwrap().common;
|
||||||
|
let shared = common.to_client_config("127.0.0.1:2112", Duration::from_secs(30));
|
||||||
|
|
||||||
assert_eq!(client.server_addr, tui.server_addr);
|
assert_eq!(shared.server_addr, tui.server_addr);
|
||||||
assert_eq!(client.duration, tui.duration);
|
assert_eq!(shared.duration, tui.duration);
|
||||||
assert_eq!(client.interval, tui.interval);
|
assert_eq!(shared.interval, tui.interval);
|
||||||
assert_eq!(client.length, tui.length);
|
assert_eq!(shared.length, tui.length);
|
||||||
assert_eq!(client.received_stats, tui.received_stats);
|
assert_eq!(shared.received_stats, tui.received_stats);
|
||||||
assert_eq!(client.stamp_at, tui.stamp_at);
|
assert_eq!(shared.stamp_at, tui.stamp_at);
|
||||||
assert_eq!(client.clock, tui.clock);
|
assert_eq!(shared.clock, tui.clock);
|
||||||
assert_eq!(client.dscp, tui.dscp);
|
assert_eq!(shared.dscp, tui.dscp);
|
||||||
assert_eq!(client.hmac_key, tui.hmac_key);
|
assert_eq!(shared.hmac_key, tui.hmac_key);
|
||||||
assert_eq!(client.server_fill, tui.server_fill);
|
assert_eq!(shared.server_fill, tui.server_fill);
|
||||||
assert_eq!(client.negotiation_policy, tui.negotiation_policy);
|
assert_eq!(shared.negotiation_policy, tui.negotiation_policy);
|
||||||
assert_eq!(client.socket_config.ttl, tui.socket_config.ttl);
|
assert_eq!(shared.socket_config.ttl, tui.socket_config.ttl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client-runtime")]
|
||||||
pub mod client;
|
pub mod client;
|
||||||
+1
-1
@@ -11,4 +11,4 @@ ci = "github"
|
|||||||
installers = []
|
installers = []
|
||||||
# Target platforms to build apps for (Rust target-triple syntax)
|
# Target platforms to build apps for (Rust target-triple syntax)
|
||||||
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
|
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
|
||||||
features = ["tui"]
|
features = ["full"]
|
||||||
Reference in new issue
Block a user