Skip to content

Commit

Permalink
feat(publish): with retain argument
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Jan 12, 2021
1 parent a8a19bf commit d6a5f6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pub fn build() -> App<'static, 'static> {
.help("Payload to be published")
.required(true),
)
.arg(
Arg::with_name("retain")
.short("r")
.long("retain")
.help("Publish the MQTT message retained"),
)
.arg(
Arg::with_name("verbose")
.short("v")
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn main() -> Result<(), Box<dyn Error>> {

if let Some(matches) = matches.subcommand_matches("publish") {
let verbose = matches.is_present("verbose");
let retain = matches.is_present("retain");

let topic = matches
.value_of("Topic")
Expand All @@ -42,7 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.value_of("Payload")
.expect("Topic could not be read from command line");

client.publish(topic, QoS::AtLeastOnce, false, payload)?;
client.publish(topic, QoS::AtLeastOnce, retain, payload)?;

publish::eventloop(client, connection, verbose);
} else {
Expand Down

0 comments on commit d6a5f6c

Please sign in to comment.