chore(cli): gracefull failback if API format changes
ci/woodpecker/push/woodpecker Pipeline failed Details

feat/type-attributes
Tomáš Mládek 2023-06-06 20:23:20 +02:00
parent df98df7394
commit 37e9ccec56
1 changed files with 21 additions and 5 deletions

View File

@ -545,11 +545,27 @@ async fn print_response_entries(response: reqwest::Response, format: OutputForma
entries.for_each(|(_, entry)| {
println!(
"{}\t{}\t{}\t{}\t{}",
entry.get("entity").and_then(|e| e.as_str()).unwrap(),
entry.get("attribute").and_then(|a| a.as_str()).unwrap(),
entry.get("value").and_then(|v| v.get("c")).unwrap(),
entry.get("timestamp").and_then(|t| t.as_str()).unwrap(),
entry.get("provenance").and_then(|p| p.as_str()).unwrap(),
entry
.get("entity")
.and_then(|e| e.as_str())
.unwrap_or("???"),
entry
.get("attribute")
.and_then(|a| a.as_str())
.unwrap_or("???"),
entry
.get("value")
.and_then(|v| v.get("c"))
.map(|c| format!("{c}"))
.unwrap_or("???".to_string()),
entry
.get("timestamp")
.and_then(|t| t.as_str())
.unwrap_or("???"),
entry
.get("provenance")
.and_then(|p| p.as_str())
.unwrap_or("???"),
)
})
}