use crate::ui::UI;
use anyhow::Result;
use vx_plugin::PluginRegistry;
pub async fn handle(
registry: &PluginRegistry,
tool_name: &str,
args: &[String],
use_system_path: bool,
) -> Result<()> {
let exit_code = execute_tool(registry, tool_name, args, use_system_path).await?;
if exit_code != 0 {
std::process::exit(exit_code);
}
Ok(())
}
pub async fn execute_tool(
_registry: &PluginRegistry,
tool_name: &str,
args: &[String],
_use_system_path: bool,
) -> Result<i32> {
UI::debug(&format!("Executing: {} {}", tool_name, args.join(" ")));
execute_system_tool(tool_name, args).await
}
async fn execute_system_tool(tool_name: &str, args: &[String]) -> Result<i32> {
let status = std::process::Command::new(tool_name)
.args(args)
.status()
.map_err(|_| anyhow::anyhow!("Tool not found: {}", tool_name))?;
Ok(status.code().unwrap_or(1))
}