(
action: AutomationRunsAction,
)
| 15 | } |
| 16 | |
| 17 | async fn handle_automation_runs_command( |
| 18 | action: AutomationRunsAction, |
| 19 | ) -> tracedecay::errors::Result<()> { |
| 20 | use tracedecay::automation::run_ledger::{ |
| 21 | find_run_record, load_run_records, read_run_artifact_payload, |
| 22 | }; |
| 23 | |
| 24 | let path = match &action { |
| 25 | AutomationRunsAction::List { path, .. } |
| 26 | | AutomationRunsAction::View { path, .. } |
| 27 | | AutomationRunsAction::Artifact { path, .. } => path.clone(), |
| 28 | }; |
| 29 | let project_path = resolve_cli_project_root(path, None, None).await?; |
| 30 | let cg = crate::serve::ensure_initialized(&project_path).await?; |
| 31 | let dashboard_root = cg.store_layout().dashboard_root.clone(); |
| 32 | |
| 33 | match action { |
| 34 | AutomationRunsAction::List { limit, json, .. } => { |
| 35 | let limit = limit.min(200); |
| 36 | let records = load_run_records(&dashboard_root, limit).await?; |
| 37 | if json { |
| 38 | println!( |
| 39 | "{}", |
| 40 | serde_json::to_string_pretty(&serde_json::json!({ |
| 41 | "dashboard_root": dashboard_root, |
| 42 | "count": records.len(), |
| 43 | "limit": limit, |
| 44 | "records": records, |
| 45 | }))? |
| 46 | ); |
| 47 | } else { |
| 48 | print_automation_run_list(&records); |
| 49 | } |
| 50 | } |
| 51 | AutomationRunsAction::View { run_id, json, .. } => { |
| 52 | let record = find_run_record(&dashboard_root, &run_id) |
| 53 | .await? |
| 54 | .ok_or_else(|| tracedecay::errors::TraceDecayError::Config { |
| 55 | message: format!("automation run not found: {run_id}"), |
| 56 | })?; |
| 57 | if json { |
| 58 | println!( |
| 59 | "{}", |
| 60 | serde_json::to_string_pretty(&serde_json::json!({ |
| 61 | "dashboard_root": dashboard_root, |
| 62 | "record": record, |
| 63 | }))? |
| 64 | ); |
| 65 | } else { |
| 66 | print_automation_run_record(&record); |
| 67 | } |
| 68 | } |
| 69 | AutomationRunsAction::Artifact { |
| 70 | run_id, kind, json, .. |
| 71 | } => { |
| 72 | let record = find_run_record(&dashboard_root, &run_id) |
| 73 | .await? |
| 74 | .ok_or_else(|| tracedecay::errors::TraceDecayError::Config { |
no test coverage detected