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

Method run

atomic-cli/src/commands/intent/list.rs:231–297  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

229
230impl Command for IntentList {
231 fn run(&self) -> CliResult<()> {
232 let root = find_repository_root()?;
233 let repo = Repository::open(&root).map_err(CliError::Repository)?;
234
235 // Resolve the verifying identity ONCE (soft-fail to "no identity").
236 let verifier = resolve_verifier(&self.identity)?;
237
238 // Enumerate via the SAME source `atomic vault intent list` uses; already
239 // sorted by id. Attestation entries are never in `manifest.intents`.
240 let intents = repo.vault_intent_list(None).map_err(CliError::Repository)?;
241
242 let rows: Vec<Row> = intents
243 .iter()
244 .map(|info| compute_row(&repo, info, verifier.as_ref()))
245 .collect();
246
247 if self.json {
248 let json: Vec<serde_json::Value> = rows
249 .iter()
250 .map(|r| {
251 serde_json::json!({
252 "id": r.human_key,
253 "status": r.status,
254 "attested": r.attested.json(),
255 "verifies": r.verifies.json(),
256 })
257 })
258 .collect();
259 println!("{}", serde_json::to_string_pretty(&json).unwrap());
260 return Ok(());
261 }
262
263 if rows.is_empty() {
264 println!("No intents found.");
265 return Ok(());
266 }
267
268 // Fixed-width, left-aligned columns with a header row.
269 let key_w = rows
270 .iter()
271 .map(|r| r.human_key.chars().count())
272 .chain(std::iter::once("humanKey".chars().count()))
273 .max()
274 .unwrap_or(8);
275 let status_w = rows
276 .iter()
277 .map(|r| r.status.chars().count())
278 .chain(std::iter::once("status".chars().count()))
279 .max()
280 .unwrap_or(6);
281
282 println!(
283 " {:<key_w$} {:<status_w$} {:<8} verifies",
284 "humanKey", "status", "attested",
285 );
286 for r in &rows {
287 println!(
288 " {:<key_w$} {:<status_w$} {:<8} {}",

Callers

nothing calls this directly

Calls 8

find_repository_rootFunction · 0.85
vault_intent_listMethod · 0.80
as_refMethod · 0.80
resolve_verifierFunction · 0.70
compute_rowFunction · 0.70
iterMethod · 0.45
is_emptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected