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

Function print_activity_chain

atomic-cli/src/commands/provenance/command.rs:290–373  ·  view source on GitHub ↗

Print one activity and walk its `turnParent` chain via `previous`.

(repo: &Repository, input: &ProvActivityInput, graph: &ProvenanceGraph)

Source from the content-addressed store, hash-verified

288
289/// Print one activity and walk its `turnParent` chain via `previous`.
290fn print_activity_chain(repo: &Repository, input: &ProvActivityInput, graph: &ProvenanceGraph) {
291 // The projected (unsigned) value is the source of truth for the shape.
292 let value = project(input);
293 let activity = value
294 .get("@graph")
295 .and_then(|g| g.as_array())
296 .and_then(|nodes| {
297 nodes
298 .iter()
299 .find(|n| n.get("@type").and_then(|t| t.as_str()) == Some("prov:Activity"))
300 });
301
302 let indent = " ";
303 if let Some(act) = activity {
304 println!(
305 "{indent}{} {}",
306 emphasis("activity"),
307 info(act.get("@id").and_then(|v| v.as_str()).unwrap_or("?"))
308 );
309 if let Some(gen) = act.get("generated").and_then(|v| v.as_array()) {
310 for g in gen {
311 println!(
312 "{indent} {} {}",
313 hint("generated"),
314 info(g.as_str().unwrap_or("?"))
315 );
316 }
317 }
318 println!(
319 "{indent} {} {}",
320 hint("agent"),
321 info(
322 act.get("associatedWith")
323 .and_then(|v| v.as_str())
324 .unwrap_or("?")
325 )
326 );
327 println!(
328 "{indent} {} {} ({})",
329 hint("agent label"),
330 info(&input.agent_display_name),
331 input.agent_vendor.as_deref().unwrap_or("no vendor")
332 );
333 println!(
334 "{indent} {} {}",
335 hint("person"),
336 info(
337 act.get("actedOnBehalfOf")
338 .and_then(|v| v.as_str())
339 .unwrap_or("?")
340 )
341 );
342 if let Some(parent) = act.get("turnParent").and_then(|v| v.as_str()) {
343 println!("{indent} {} {}", hint("turnParent"), info(parent));
344 } else {
345 println!("{indent} {}", hint("turnParent: (root turn)"));
346 }
347 }

Callers 1

print_traceFunction · 0.85

Calls 5

projectFunction · 0.85
getMethod · 0.65
iterMethod · 0.45
as_strMethod · 0.45
load_provenance_graphMethod · 0.45

Tested by

no test coverage detected