(graph: &ProvenanceGraph)
| 378 | } |
| 379 | |
| 380 | fn ledger(graph: &ProvenanceGraph) -> Tree { |
| 381 | let mut section = Tree::new("Change Ledger"); |
| 382 | section.push(format!("Session: {}", graph.session_id)); |
| 383 | section.push(format!( |
| 384 | "Agent: {} ({})", |
| 385 | graph.agent_display_name, graph.agent_vendor |
| 386 | )); |
| 387 | section.push(format!( |
| 388 | "Nodes: {} Edges: {} Changes: {}", |
| 389 | graph.node_count(), |
| 390 | graph.edge_count(), |
| 391 | graph.change_count() |
| 392 | )); |
| 393 | for node in &graph.nodes { |
| 394 | let tool = node |
| 395 | .tool_name |
| 396 | .as_ref() |
| 397 | .map(|tool| format!(" [{tool}]")) |
| 398 | .unwrap_or_default(); |
| 399 | let duration = node |
| 400 | .duration_ms |
| 401 | .map(|ms| format!(" ({ms}ms)")) |
| 402 | .unwrap_or_default(); |
| 403 | let mut entry = Tree::new(format!("{}: {}{tool}{duration}", node.kind, node.summary)); |
| 404 | if let Some(detail) = node |
| 405 | .detail |
| 406 | .as_ref() |
| 407 | .and_then(|detail| command::format_node_detail(detail)) |
| 408 | { |
| 409 | entry.push(detail); |
| 410 | } |
| 411 | section.children.push(entry); |
| 412 | } |
| 413 | section |
| 414 | } |
| 415 | |
| 416 | #[cfg(test)] |
| 417 | mod tests { |
no test coverage detected