(
action: AutomationConfigAction,
)
| 618 | } |
| 619 | |
| 620 | async fn handle_automation_config_command( |
| 621 | action: AutomationConfigAction, |
| 622 | ) -> tracedecay::errors::Result<()> { |
| 623 | use tracedecay::automation::config::{ |
| 624 | apply_project_config_patch, effective_config, load_project_config, AutomationBackend, |
| 625 | AutomationConfigPatch, |
| 626 | }; |
| 627 | |
| 628 | let path = match &action { |
| 629 | AutomationConfigAction::Get { path, .. } |
| 630 | | AutomationConfigAction::Explain { path, .. } |
| 631 | | AutomationConfigAction::Enable { path, .. } |
| 632 | | AutomationConfigAction::Disable { path, .. } |
| 633 | | AutomationConfigAction::Set { path, .. } => path.clone(), |
| 634 | }; |
| 635 | let scope = match &action { |
| 636 | AutomationConfigAction::Get { scope, .. } |
| 637 | | AutomationConfigAction::Explain { scope, .. } |
| 638 | | AutomationConfigAction::Enable { scope, .. } |
| 639 | | AutomationConfigAction::Disable { scope, .. } |
| 640 | | AutomationConfigAction::Set { scope, .. } => *scope, |
| 641 | }; |
| 642 | |
| 643 | let mut user_config = tracedecay::user_config::UserConfig::load(); |
| 644 | let global = user_config.automation.clone(); |
| 645 | let project_context = if scope == AutomationConfigScope::Project { |
| 646 | let project_path = resolve_cli_project_root(path, None, None).await?; |
| 647 | let cg = crate::serve::ensure_initialized(&project_path).await?; |
| 648 | Some(( |
| 649 | cg.store_layout().dashboard_root.clone(), |
| 650 | load_project_config(&cg.store_layout().dashboard_root).await?, |
| 651 | )) |
| 652 | } else { |
| 653 | None |
| 654 | }; |
| 655 | |
| 656 | let patch = match action { |
| 657 | AutomationConfigAction::Get { json, .. } => { |
| 658 | let project = project_context |
| 659 | .as_ref() |
| 660 | .and_then(|(_, project)| project.as_ref()); |
| 661 | let effective = effective_config(&global, project)?; |
| 662 | print_automation_config(&global, project, &effective, json, false)?; |
| 663 | return Ok(()); |
| 664 | } |
| 665 | AutomationConfigAction::Explain { json, .. } => { |
| 666 | let project = project_context |
| 667 | .as_ref() |
| 668 | .and_then(|(_, project)| project.as_ref()); |
| 669 | let effective = effective_config(&global, project)?; |
| 670 | print_automation_config(&global, project, &effective, json, true)?; |
| 671 | return Ok(()); |
| 672 | } |
| 673 | AutomationConfigAction::Enable { .. } => AutomationConfigPatch { |
| 674 | enabled: Some(true), |
| 675 | backend: Some(AutomationBackend::CodexAppServer), |
| 676 | ..AutomationConfigPatch::default() |
| 677 | }, |
no test coverage detected