summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge/src/cli/mqtt/cli.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-01-10 08:49:09 +0100
committerMatthias Beyer <matthias.beyer@ifm.com>2022-02-18 15:41:57 +0100
commitdf052450ba30e55b5dcd464bca5236e1e995a2b9 (patch)
tree11ec5465c22459808055744582b6554d9f4bc624 /crates/core/tedge/src/cli/mqtt/cli.rs
parentee2a1c14f338fe5e433d4d58a862994d60fb18f7 (diff)
Replace structopt with clap 3
This patch rewrites the CLI interfaces to be used with clap 3.0 instead of clap 2.x + structopt. The changes are as minimal as possible, although I did not verify that the CLI is the same as before. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'crates/core/tedge/src/cli/mqtt/cli.rs')
-rw-r--r--crates/core/tedge/src/cli/mqtt/cli.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/core/tedge/src/cli/mqtt/cli.rs b/crates/core/tedge/src/cli/mqtt/cli.rs
index 32f4906f..f6878a78 100644
--- a/crates/core/tedge/src/cli/mqtt/cli.rs
+++ b/crates/core/tedge/src/cli/mqtt/cli.rs
@@ -2,7 +2,6 @@ use crate::cli::mqtt::{publish::MqttPublishCommand, subscribe::MqttSubscribeComm
use crate::command::{BuildCommand, BuildContext, Command};
use rumqttc::QoS;
use std::time::Duration;
-use structopt::StructOpt;
use tedge_config::*;
const DEFAULT_HOST: &str = "localhost";
@@ -10,7 +9,7 @@ const PUB_CLIENT_PREFIX: &str = "tedge-pub";
const SUB_CLIENT_PREFIX: &str = "tedge-sub";
const DISCONNECT_TIMEOUT: Duration = Duration::from_secs(2);
-#[derive(StructOpt, Debug)]
+#[derive(clap::Subcommand, Debug)]
pub enum TEdgeMqttCli {
/// Publish a MQTT message on a topic.
Pub {
@@ -19,10 +18,10 @@ pub enum TEdgeMqttCli {
/// Message to publish
message: String,
/// QoS level (0, 1, 2)
- #[structopt(short, long, parse(try_from_str = parse_qos), default_value = "0")]
+ #[clap(short, long, parse(try_from_str = parse_qos), default_value = "0")]
qos: QoS,
/// Retain flag
- #[structopt(short, long = "retain")]
+ #[clap(short, long = "retain")]
retain: bool,
},
@@ -31,10 +30,10 @@ pub enum TEdgeMqttCli {
/// Topic to subscribe to
topic: String,
/// QoS level (0, 1, 2)
- #[structopt(short, long, parse(try_from_str = parse_qos), default_value = "0")]
+ #[clap(short, long, parse(try_from_str = parse_qos), default_value = "0")]
qos: QoS,
/// Avoid printing the message topics on the console
- #[structopt(long = "no-topic")]
+ #[clap(long = "no-topic")]
hide_topic: bool,
},
}