vx_cli/commands/
execute.rs

1//! Execute command implementation - Transparent proxy for tool execution
2
3use crate::ui::UI;
4use anyhow::Result;
5use vx_plugin::PluginRegistry;
6// TODO: DynamicExecutor needs to be implemented or imported from appropriate crate
7
8/// Handle the execute command
9pub async fn handle(
10    registry: &PluginRegistry,
11    tool_name: &str,
12    args: &[String],
13    use_system_path: bool,
14) -> Result<()> {
15    let exit_code = execute_tool(registry, tool_name, args, use_system_path).await?;
16    if exit_code != 0 {
17        std::process::exit(exit_code);
18    }
19    Ok(())
20}
21
22/// Execute tool with given arguments (simplified for closed-loop toolchain)
23pub async fn execute_tool(
24    _registry: &PluginRegistry,
25    tool_name: &str,
26    args: &[String],
27    _use_system_path: bool,
28) -> Result<i32> {
29    UI::debug(&format!("Executing: {} {}", tool_name, args.join(" ")));
30
31    // For now, use direct system execution
32    // TODO: Implement smart tool resolution with vx-managed tools
33    execute_system_tool(tool_name, args).await
34}
35
36/// Execute a tool using system PATH
37async fn execute_system_tool(tool_name: &str, args: &[String]) -> Result<i32> {
38    let status = std::process::Command::new(tool_name)
39        .args(args)
40        .status()
41        .map_err(|_| anyhow::anyhow!("Tool not found: {}", tool_name))?;
42
43    Ok(status.code().unwrap_or(1))
44}