MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_node_detail

Function format_node_detail

atomic-cli/src/commands/change/command.rs:687–716  ·  view source on GitHub ↗

Extract a human-readable one-liner from a provenance node's detail JSON. Returns `None` if the detail is empty or has no interesting fields.

(detail: &str)

Source from the content-addressed store, hash-verified

685///
686/// Returns `None` if the detail is empty or has no interesting fields.
687fn format_node_detail(detail: &str) -> Option<String> {
688 let v: serde_json::Value = serde_json::from_str(detail).ok()?;
689 let obj = v.as_object()?;
690
691 // Command (bash/execution nodes)
692 if let Some(cmd) = obj.get("command").and_then(|v| v.as_str()) {
693 return Some(format!("$ {}", truncate_bytes(cmd, 120)));
694 }
695
696 // File path (read/write/edit nodes)
697 if let Some(file) = obj
698 .get("file")
699 .or_else(|| obj.get("file_path"))
700 .or_else(|| obj.get("target"))
701 .and_then(|v| v.as_str())
702 {
703 let op = obj.get("operation").and_then(|v| v.as_str()).unwrap_or("");
704 if op.is_empty() {
705 return Some(file.to_string());
706 }
707 return Some(format!("{}: {}", op, file));
708 }
709
710 // Output summary (fallback for nodes with only output)
711 if let Some(summary) = obj.get("output_summary").and_then(|v| v.as_str()) {
712 return Some(truncate_bytes(summary, 120));
713 }
714
715 None
716}
717
718impl Default for ChangeCmd {
719 fn default() -> Self {

Callers 1

format_change_ledgerMethod · 0.85

Calls 4

truncate_bytesFunction · 0.85
getMethod · 0.65
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected