From d782334d31e2925432677d1e05d000f350aa925d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 May 2020 20:23:48 +0200 Subject: bin/zot: Clean up channel stream output somewhat. Not really easy to find a goot pure text representation of this, though. --- src/bin/zot/zot/channel_stream.rs | 27 ++++++++++++++++++--------- 1 file 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"])); } -- cgit v1.2.3