vx_cli/commands/
where_cmd.rs1use crate::ui::UI;
4use anyhow::Result;
5use vx_paths::{PathManager, PathResolver};
6use vx_plugin::PluginRegistry;
7
8pub async fn handle(_registry: &PluginRegistry, tool: &str, all: bool) -> Result<()> {
9 UI::debug(&format!("Looking for vx-managed tool: {}", tool));
10
11 let path_manager = PathManager::new()
13 .map_err(|e| anyhow::anyhow!("Failed to initialize path manager: {}", e))?;
14 let resolver = PathResolver::new(path_manager);
15
16 let locations = if all {
17 resolver.find_tool_executables(tool)?
19 } else {
20 match resolver.find_latest_executable(tool)? {
22 Some(path) => vec![path],
23 None => vec![],
24 }
25 };
26
27 if locations.is_empty() {
28 UI::error(&format!(
29 "Tool '{}' not found in vx-managed installations",
30 tool
31 ));
32 UI::hint("Use 'vx list' to see installed tools");
33 UI::hint(&format!("Use 'vx install {}' to install this tool", tool));
34 std::process::exit(1);
35 }
36
37 for location in locations {
38 println!("{}", location.display());
39 }
40
41 Ok(())
42}