From 3404e82e40ffd1055d89d72abe0e36bc8b24a656 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 12 Jun 2019 14:40:56 +0200 Subject: zotcli: Handle attaching media to posts. --- examples/zot/item.rs | 7 ++++++- examples/zotcli.rs | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/zot/item.rs b/examples/zot/item.rs index 5c3bd40..eb9013f 100644 --- a/examples/zot/item.rs +++ b/examples/zot/item.rs @@ -21,10 +21,15 @@ use zotapi; pub fn post(client: &zotapi::Client, args: &ArgMatches) { let mut msg = client.item(); msg.body(args.value_of("BODY").unwrap()); - if let Some(title) = args.value_of("TITLE") { + + if let Some(title) = dbg!(args.value_of("TITLE")) { msg.title(title); } + if let Some(file) = dbg!(args.value_of("ATTACH")) { + msg.file(file); + } + match msg.create() { Ok(payload) => { println!("Raw payload: {}", payload); diff --git a/examples/zotcli.rs b/examples/zotcli.rs index 2599531..0925a1f 100644 --- a/examples/zotcli.rs +++ b/examples/zotcli.rs @@ -74,6 +74,7 @@ fn main() { (about: "Post a new message") (@arg BODY: +required "Body of the message") (@arg TITLE: --title +takes_value "Set a title for the message") + (@arg ATTACH: --attach [FILE] "Attach a file or image to the post") ) ) .get_matches(); -- cgit v1.2.3