aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot/item.rs
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-05-02 13:58:09 +0200
committerYour Name <you@example.com>2020-05-02 13:58:09 +0200
commite95d9f86d2d9f2e689393f1e486b6250b2b075db (patch)
treecaa5a91769c2581468e76e1a6ac68f64b6c64d35 /examples/zot/item.rs
parentf38b1cf6c5c37ea41d720a76dc928c25e7437546 (diff)
downloadrust-zotapi-e95d9f86d2d9f2e689393f1e486b6250b2b075db.tar.gz
rust-zotapi-e95d9f86d2d9f2e689393f1e486b6250b2b075db.tar.bz2
rust-zotapi-e95d9f86d2d9f2e689393f1e486b6250b2b075db.zip
zotcli: take item body as a file rather than string.
Diffstat (limited to 'examples/zot/item.rs')
-rw-r--r--examples/zot/item.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/zot/item.rs b/examples/zot/item.rs
index 2e07561..9869492 100644
--- a/examples/zot/item.rs
+++ b/examples/zot/item.rs
@@ -20,7 +20,13 @@ use zotapi;
pub fn post(client: &zotapi::Client, args: &ArgMatches) {
let mut msg = zotapi::item();
- msg.body(args.value_of("BODY").unwrap());
+ let body: String;
+
+ if let Some(file) = dbg!(args.value_of("FILE")) {
+ let buf = std::fs::read(file).expect("Invalid file name");
+ body = String::from_utf8(buf).expect("File contained invalid char data.");
+ msg.body(&body);
+ }
if let Some(title) = dbg!(args.value_of("TITLE")) {
msg.title(title);