diff options
Diffstat (limited to 'examples/zot')
-rw-r--r-- | examples/zot/item.rs | 8 |
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); |