pub fn lifecycle(shell: &str) -> Option<Diagram>Expand description
The task lifecycle as a typed diagram, derived from the text of lib/finish.sh.
The states a task can end in are not written here: they are outcomes of the source
passed in, so an outcome added to the tool appears in every rendering of the lifecycle
without anyone drawing it. The transitions that are not outcomes — start, checkpoint,
handover — are the lifecycle the workflow defines, and they are stated once, here.
use majordomus_cli::diagram::{lifecycle, Kind};
let shell = " case \"$outcome\" in completed|failed) ;;\n";
let drawn = lifecycle(shell).expect("the vocabulary is readable");
assert_eq!(drawn.kind, Kind::State);
assert_eq!(drawn.provenance.source, "lib/finish.sh");
assert!(drawn.nodes.iter().any(|n| n.id == "failed"), "every outcome is a state");
assert!(drawn.to_mermaid().contains("active --> failed: finish --outcome failed"));
assert!(drawn.validate().is_empty());
assert!(lifecycle("no case arm here").is_none(), "no vocabulary, no diagram");