The effective `kind` filter is validated and applied client-side (an unknown kind is a clean argument error, not a silent empty list); the classification itself rides the wire's VaultEntry.
(rows: &[Row], json: bool)
| 386 | /// (an unknown kind is a clean argument error, not a silent empty |
| 387 | /// list); the classification itself rides the wire's VaultEntry. |
| 388 | pub(crate) fn render(rows: &[Row], json: bool) { |
| 389 | if json { |
| 390 | let json: Vec<serde_json::Value> = rows |
| 391 | .iter() |
| 392 | .map(|r| { |
| 393 | serde_json::json!({ |
| 394 | "id": r.human_key, |
| 395 | // Omitted entirely before, so every API consumer |
| 396 | // reported an intent's title as null however well |
| 397 | // the frontmatter named it. |
| 398 | "title": r.title, |
| 399 | "status": r.status, |
| 400 | "kind": r.kind, |
| 401 | "attested": r.attested.json(), |
| 402 | "verifies": r.verifies.json(), |
| 403 | }) |
| 404 | }) |
| 405 | .collect(); |
| 406 | println!("{}", serde_json::to_string_pretty(&json).unwrap()); |
| 407 | return; |
| 408 | } |
| 409 | if rows.is_empty() { |
| 410 | println!("No intents found."); |
| 411 | return; |
| 412 | } |
| 413 | // Fixed-width, left-aligned columns with a header row. |
| 414 | let key_w = rows |
| 415 | .iter() |
| 416 | .map(|r| r.human_key.chars().count()) |
| 417 | .chain(std::iter::once("humanKey".chars().count())) |
| 418 | .max() |
| 419 | .unwrap_or(8); |
| 420 | let status_w = rows |
| 421 | .iter() |
| 422 | .map(|r| r.status.chars().count()) |
| 423 | .chain(std::iter::once("status".chars().count())) |
| 424 | .max() |
| 425 | .unwrap_or(6); |
| 426 | // The kind column renders as a `[tag]`, so size on the bracketed width. |
| 427 | let kind_w = rows |
| 428 | .iter() |
| 429 | .map(|r| r.kind.chars().count() + 2) |
| 430 | .chain(std::iter::once("kind".chars().count())) |
| 431 | .max() |
| 432 | .unwrap_or(4); |
| 433 | |
| 434 | println!( |
| 435 | " {:<key_w$} {:<status_w$} {:<kind_w$} {:<8} verifies", |
| 436 | "humanKey", "status", "kind", "attested", |
| 437 | ); |
| 438 | for r in rows { |
| 439 | println!( |
| 440 | " {:<key_w$} {:<status_w$} {:<kind_w$} {:<8} {}", |
| 441 | r.human_key, |
| 442 | r.status, |
| 443 | format!("[{}]", r.kind), |
| 444 | r.attested.table(), |
| 445 | r.verifies.table(), |
no test coverage detected