summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_agent/src/main.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_agent/src/main.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_agent/src/main.rs')
-rw-r--r--crates/core/tedge_agent/src/main.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/core/tedge_agent/src/main.rs b/crates/core/tedge_agent/src/main.rs
index abe34344..e6492d2c 100644
--- a/crates/core/tedge_agent/src/main.rs
+++ b/crates/core/tedge_agent/src/main.rs
@@ -1,5 +1,5 @@
use agent::SmAgentConfig;
-use structopt::*;
+use clap::Parser;
mod agent;
mod error;
@@ -7,8 +7,8 @@ mod operation_logs;
mod restart_operation_handler;
mod state;
-#[derive(Debug, StructOpt)]
-#[structopt(
+#[derive(Debug, clap::Parser)]
+#[clap(
name = clap::crate_name!(),
version = clap::crate_version!(),
about = clap::crate_description!()
@@ -18,23 +18,23 @@ pub struct AgentOpt {
///
/// If off only reports ERROR, WARN, and INFO
/// If on also reports DEBUG and TRACE
- #[structopt(long)]
+ #[clap(long)]
pub debug: bool,
/// Start the agent with clean session off, subscribe to the topics, so that no messages are lost
- #[structopt(short, long)]
+ #[clap(short, long)]
pub init: bool,
/// Start the agent with clean session on, drop the previous session and subscriptions
///
/// WARNING: All pending messages will be lost.
- #[structopt(short, long)]
+ #[clap(short, long)]
pub clear: bool,
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
- let agent_opt = AgentOpt::from_args();
+ let agent_opt = AgentOpt::parse();
tedge_utils::logging::initialise_tracing_subscriber(agent_opt.debug);
let tedge_config_location = tedge_config::TEdgeConfigLocation::from_default_system_location();
let mut agent = agent::SmAgent::try_new(