Skip to content

Commit

Permalink
cli: show comments only when present
Browse files Browse the repository at this point in the history
  • Loading branch information
nain-F49FF806 authored and Mydayyy committed Apr 27, 2024
1 parent 09d7399 commit 6b6e575
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ fn handle_get(opts: &Opts) -> PbResult<()> {
std::io::stdout().write_all(content.paste.as_bytes())?;
} else {
let mut output: Value = serde_json::to_value(content)?;
let comments_trees =
paste.comments_formatted_json_trees(&comments, &paste.comments_adjacency_map()?)?;
output["comments"] = serde_json::from_str(&comments_trees)?;
if !comments.is_empty() {
let comments_trees =
paste.comments_formatted_json_trees(&comments, &paste.comments_adjacency_map()?)?;
output["comments"] = serde_json::from_str(&comments_trees)?;
}
std::io::stdout().write_all(serde_json::to_string_pretty(&output)?.as_bytes())?;
}

Expand Down

0 comments on commit 6b6e575

Please sign in to comment.