(&self)
| 26 | |
| 27 | impl Command for IntentShow { |
| 28 | fn run(&self) -> CliResult<()> { |
| 29 | let root = find_repository_root()?; |
| 30 | let repo = Repository::open(&root).map_err(CliError::Repository)?; |
| 31 | |
| 32 | // Pure read-time projection: lift then render. No gate, no proof |
| 33 | // requirement — this must work on a plain (un-attested) intent. The |
| 34 | // status line is regenerated from the spine by the renderer. If a FRESH |
| 35 | // attestation sidecar exists we project that (so `show` reflects the |
| 36 | // attested author/proof); a stale one warns and falls back to the raw node. |
| 37 | let inputs = bridge::read_intent(&repo, &self.id)?; |
| 38 | let node = match bridge::load_attestation(&repo, &self.id, &inputs)? { |
| 39 | bridge::Attestation::Fresh(node) => *node, |
| 40 | bridge::Attestation::Stale(_) => { |
| 41 | eprintln!( |
| 42 | "warning: the attestation for {} is stale; showing the current \ |
| 43 | (un-attested) intent.", |
| 44 | self.id |
| 45 | ); |
| 46 | bridge::lift(&inputs)? |
| 47 | } |
| 48 | bridge::Attestation::None => bridge::lift(&inputs)?, |
| 49 | }; |
| 50 | |
| 51 | if self.json { |
| 52 | // The canonical JSON already carries `kind` (when non-default) and the |
| 53 | // `reviews` refs under `dependsOn`, so no supplement is needed here. |
| 54 | println!( |
| 55 | "{}", |
| 56 | serde_json::to_string_pretty(&node.to_value()).unwrap() |
| 57 | ); |
| 58 | } else { |
| 59 | print!("{}", render(&node, Target::Cli)); |
| 60 | // The renderer has no `kind` field of its own, so surface the |
| 61 | // classification (and, for a review, what it reviews) here. |
| 62 | println!("Kind: {}", node.kind); |
| 63 | if node.kind == "review" { |
| 64 | let targets: Vec<&str> = node |
| 65 | .depends_on |
| 66 | .iter() |
| 67 | .filter(|r| r.edge == "reviews") |
| 68 | .map(|r| r.to.as_str()) |
| 69 | .collect(); |
| 70 | if targets.is_empty() { |
| 71 | println!("Reviews: (none declared)"); |
| 72 | } else { |
| 73 | println!("Reviews:"); |
| 74 | for t in targets { |
| 75 | println!(" • {t}"); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | Ok(()) |
| 82 | } |
| 83 | } |
nothing calls this directly
no test coverage detected