vx_cli/commands/
execute.rs1use crate::ui::UI;
4use anyhow::Result;
5use vx_plugin::PluginRegistry;
6pub 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
22pub 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 execute_system_tool(tool_name, args).await
34}
35
36async 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}