diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2023-01-16 09:59:44 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2023-01-19 09:57:51 +0100 |
commit | 99a0e80c89079302e1582f560ebc91dcc2e0acba (patch) | |
tree | 6a201ce3c43ce88d00473d888c18e8b9077ef06f | |
parent | a2042408ea2771d137ecbc7a8de11c80f784626c (diff) |
Fix: Make command optional
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/bin/cloudmqtt-test-client.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/bin/cloudmqtt-test-client.rs b/src/bin/cloudmqtt-test-client.rs index e21f554..8f58159 100644 --- a/src/bin/cloudmqtt-test-client.rs +++ b/src/bin/cloudmqtt-test-client.rs @@ -25,7 +25,7 @@ fn print_error_and_quit(e: String) -> ! { #[derive(clap::Parser, Debug)] struct Args { #[command(subcommand)] - command: Command, + command: Option<Command>, } #[derive(clap::Subcommand, Debug)] @@ -100,25 +100,25 @@ async fn main() { for arg in args { match arg.command { - Command::Quit => {} - Command::Subscribe { topic } => { + Some(Command::Quit) => {} + Some(Command::Subscribe { topic }) => { let subscription_requests = [MSubscriptionRequest { topic: MString { value: &topic }, qos: MQualityOfService::AtMostOnce, // TODO }]; client.subscribe(&subscription_requests).await.unwrap(); } - Command::SendToTopic { + Some(Command::SendToTopic { topic: _, qos: _, message: _, - } => { + }) => { unimplemented!() } - Command::ExpectOnTopic { + Some(Command::ExpectOnTopic { topic: expected_topic, qos: expected_qos, - } => { + }) => { let packet = match packet_stream.next().await { Some(Ok(packet)) => packet, None => { @@ -153,6 +153,10 @@ async fn main() { break; } } + + None => { + // no command, doing nothing + } } } } |