(config: CliConfig, args: ExecCommandArgs)
| 24 | } |
| 25 | |
| 26 | pub async fn handle_exec_command(config: CliConfig, args: ExecCommandArgs) -> Result<()> { |
| 27 | let workspace_path_resolved = std::env::current_dir().ok(); |
| 28 | |
| 29 | if let Some(ref ws_path) = workspace_path_resolved { |
| 30 | tracing::info!("Workspace path set: {:?}", ws_path); |
| 31 | } |
| 32 | |
| 33 | let message = resolve_exec_message(args.message)?; |
| 34 | let resume = match (args.resume, args.session) { |
| 35 | (Some(_), Some(_)) => { |
| 36 | anyhow::bail!("Use only one of --resume or --session"); |
| 37 | } |
| 38 | (Some(value), None) | (None, Some(value)) => Some(value), |
| 39 | (None, None) => None, |
| 40 | }; |
| 41 | if args.session_id.is_some() && (args.continue_last || resume.is_some()) { |
| 42 | anyhow::bail!("--session-id cannot be combined with --continue, --resume, or --session"); |
| 43 | } |
| 44 | if args.fork_session && args.session_id.is_some() { |
| 45 | anyhow::bail!("--fork-session cannot be combined with --session-id"); |
| 46 | } |
| 47 | |
| 48 | let skip_confirmation = !args.confirm; |
| 49 | let (agentic_system, original_skip_confirmation) = |
| 50 | crate::initialize_core_services(skip_confirmation).await?; |
| 51 | |
| 52 | let mut exec_mode = ExecMode::new( |
| 53 | config, |
| 54 | message, |
| 55 | args.agent, |
| 56 | &agentic_system, |
| 57 | workspace_path_resolved, |
| 58 | args.output_patch, |
| 59 | args.output_format, |
| 60 | ExecSessionOptions { |
| 61 | resume, |
| 62 | continue_last: args.continue_last, |
| 63 | session_id: args.session_id, |
| 64 | fork_session: args.fork_session, |
| 65 | }, |
| 66 | ); |
| 67 | let run_result = exec_mode.run().await; |
| 68 | |
| 69 | crate::shutdown_mcp_servers().await; |
| 70 | crate::restore_tool_confirmation(original_skip_confirmation).await; |
| 71 | |
| 72 | run_result |
| 73 | } |
| 74 | |
| 75 | fn resolve_exec_message(message: Option<String>) -> Result<String> { |
| 76 | let mut combined = message.unwrap_or_default(); |
no test coverage detected