diff options
author | Your Name <you@example.com> | 2020-05-03 20:23:48 +0200 |
---|---|---|
committer | Your Name <you@example.com> | 2020-05-03 20:23:48 +0200 |
commit | d782334d31e2925432677d1e05d000f350aa925d (patch) | |
tree | bc30fedb04acf7bfd01a08e43f66c893b71bea91 | |
parent | a3d33d3e680f19c0d61911d64d9e4c30a07f55ab (diff) | |
download | rust-zotapi-d782334d31e2925432677d1e05d000f350aa925d.tar.gz rust-zotapi-d782334d31e2925432677d1e05d000f350aa925d.tar.bz2 rust-zotapi-d782334d31e2925432677d1e05d000f350aa925d.zip |
bin/zot: Clean up channel stream output somewhat.
Not really easy to find a goot pure text representation of this, though.
-rw-r--r-- | src/bin/zot/zot/channel_stream.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/bin/zot/zot/channel_stream.rs b/src/bin/zot/zot/channel_stream.rs index bad7152..33ad7cf 100644 --- a/src/bin/zot/zot/channel_stream.rs +++ b/src/bin/zot/zot/channel_stream.rs @@ -40,7 +40,6 @@ fn list(payload: &str) { Ok(serde_json::Value::Array(v)) => { for item in v.into_iter() { print_item(&item); - println!("-----"); } } Ok(_) => println!("Wrong type returned, expected an array."), @@ -93,12 +92,22 @@ fn get_tags(item: &serde_json::Value) -> String { fn print_item(item: &serde_json::Value) { let author = &item["author"]; - print!("{} ", get_str(&item["created"])); - print!("{} ", get_str(&author["name"])); - println!("{} a {}", get_verb(&item), get_object_type(&item)); - println!("URL: {}", get_str(&author["url"])); - println!("Proto: {}", get_str(&author["network"])); - println!("Title: {}", get_str(&item["title"])); - println!("Tags : {}", get_tags(&item)); - println!("Message:\n{}", get_str(&item["body"])); + + println!("{} {} {} a {}:", + get_str(&item["created"]), + get_str(&author["name"]), + get_verb(&item), + get_object_type(&item)); + + let title = get_str(&item["title"]); + if title.len() > 0 { + println!("Title: {}", get_str(&item["title"])); + } + + let tags = get_tags(&item); + if tags.len() > 0 { + println!("Tags : {}", get_tags(&item)); + } + + println!("\n{}\n", get_str(&item["body"])); } |