summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-01-16 09:59:44 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-01-19 09:57:51 +0100
commit99a0e80c89079302e1582f560ebc91dcc2e0acba (patch)
tree6a201ce3c43ce88d00473d888c18e8b9077ef06f
parenta2042408ea2771d137ecbc7a8de11c80f784626c (diff)
Fix: Make command optional
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/bin/cloudmqtt-test-client.rs18
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
+ }
}
}
}