diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-06-09 21:49:11 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-06-09 21:49:11 +0200 |
commit | 051e884f55162498bae05e796b431e9122313c11 (patch) | |
tree | 34d33305d8eac20e0a41bb2b25bf9e8eceb6671f /examples/zot | |
parent | 8f352330d2189c0f6065812c7f3dbdab2e6d3c9e (diff) | |
download | rust-zotapi-051e884f55162498bae05e796b431e9122313c11.tar.gz rust-zotapi-051e884f55162498bae05e796b431e9122313c11.tar.bz2 rust-zotapi-051e884f55162498bae05e796b431e9122313c11.zip |
zotcli can now post messages with titles.
Diffstat (limited to 'examples/zot')
-rw-r--r-- | examples/zot/item.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/zot/item.rs b/examples/zot/item.rs index ede1876..5c3bd40 100644 --- a/examples/zot/item.rs +++ b/examples/zot/item.rs @@ -15,10 +15,17 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +use clap::ArgMatches; use zotapi; -pub fn post(client: &zotapi::Client, body: &str) { - match client.item().body(&body).create() { +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") { + msg.title(title); + } + + match msg.create() { Ok(payload) => { println!("Raw payload: {}", payload); }, |