Skip to content

Commit 983499b

Browse files
fix(testkit): show usage for testkit-ready --help
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent 58143eb commit 983499b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎tests/testkit/testkit/src/bin/testkit-ready.rs‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ use std::time::Duration;
1414
use testkit::{Cli, Gateway};
1515

1616
const DEFAULT_TIMEOUT_SECS: u64 = 60;
17+
const USAGE: &str = "usage: testkit-ready [TIMEOUT_SECS] (default 60)";
1718

1819
#[tokio::main(flavor = "current_thread")]
1920
async fn main() -> ExitCode {
20-
let timeout = match std::env::args().nth(1).map(|arg| arg.parse::<u64>()) {
21+
let timeout = match std::env::args().nth(1).as_deref() {
2122
None => DEFAULT_TIMEOUT_SECS,
22-
Some(Ok(secs)) => secs,
23-
Some(Err(error)) => {
24-
eprintln!("testkit-ready: invalid timeout: {error}");
25-
return ExitCode::from(2);
23+
Some("-h" | "--help") => {
24+
println!("{USAGE}");
25+
return ExitCode::SUCCESS;
2626
}
27+
Some(arg) => match arg.parse::<u64>() {
28+
Ok(secs) => secs,
29+
Err(_) => {
30+
eprintln!("testkit-ready: invalid timeout {arg:?}; {USAGE}");
31+
return ExitCode::from(2);
32+
}
33+
},
2734
};
2835
let result = async {
2936
let gateway = Gateway::from_env()?;

0 commit comments

Comments
 (0)