diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-01-08 19:12:02 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-01-08 19:27:38 +0100 |
commit | 5349a0c4320949d803df0dd8596ba8aa5497c81c (patch) | |
tree | b7eccc741e9703b2f1150e18f3010ddf11192d87 /src/bin/zot/main.rs | |
parent | d9375da4ebf466b6cbcac3b919b7226f0617a9c7 (diff) | |
download | rust-zotapi-5349a0c4320949d803df0dd8596ba8aa5497c81c.tar.gz rust-zotapi-5349a0c4320949d803df0dd8596ba8aa5497c81c.tar.bz2 rust-zotapi-5349a0c4320949d803df0dd8596ba8aa5497c81c.zip |
Add high level stream API.
Diffstat (limited to 'src/bin/zot/main.rs')
-rw-r--r-- | src/bin/zot/main.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bin/zot/main.rs b/src/bin/zot/main.rs index 63b4557..209e097 100644 --- a/src/bin/zot/main.rs +++ b/src/bin/zot/main.rs @@ -15,6 +15,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +use zotapi::Stream; + use clap::{clap_app, crate_authors, crate_version}; use dotenv::dotenv; use std::env; @@ -115,7 +117,22 @@ async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { } } ("stream", Some(_)) => { - println!("{}", z.channel_stream().await?); + let s = Stream::from_json(&z.channel_stream().await?)?; + for item in s.items { + if item.is_post() { + if item.title.len() > 0 { + println!("# {}", item.title); + } + + if item.summary.len() > 0 { + println!("Summary: {}\n", item.summary); + } else { + println!("{}\n", item.body); + } + println!(); + } + } + //println!("{}", z.channel_stream().await?); } ("export", Some(_)) => { println!("{}", z.channel_export().await?); |