vx_cli/commands/
plugin.rs

1// Plugin command implementation
2
3use crate::cli::PluginCommand;
4use crate::ui::UI;
5use anyhow::Result;
6use vx_plugin::PluginRegistry;
7
8pub async fn handle(registry: &PluginRegistry, command: PluginCommand) -> Result<()> {
9    // TODO: Replace with vx-core tool manager
10    // let tool_manager = crate::tool_manager::ToolManager::new()
11    //     .or_else(|_| crate::tool_manager::ToolManager::minimal())?;
12
13    match command {
14        PluginCommand::List {
15            enabled: _,
16            category: _,
17        } => {
18            UI::header("Available Plugins");
19
20            let plugins = registry.list_plugins();
21            if plugins.is_empty() {
22                UI::warn("No plugins registered");
23                return Ok(());
24            }
25
26            for plugin_name in plugins {
27                UI::item(&format!("📦 {}", plugin_name));
28            }
29            // for tool in tools {
30            //     let status_icon = if tool.installed { "✅" } else { "❌" };
31            //     let version_str = tool
32            //         .version
33            //         .as_ref()
34            //         .map(|v| format!(" ({v})"))
35            //         .unwrap_or_default();
36
37            //     println!(
38            //         "  {} {} - {}{}",
39            //         status_icon, tool.name, tool.description, version_str
40            //     );
41
42            //     if let Some(homepage) = &tool.homepage {
43            //         println!("    🌐 {homepage}");
44            //     }
45            // }
46        }
47
48        PluginCommand::Info { name } => {
49            UI::header(&format!("Tool: {name}"));
50            UI::warning("Plugin info not yet implemented in new architecture");
51            // match tool_manager.get_tool_info(&name) {
52            //     Ok(info) => {
53            //         UI::header(&format!("Tool: {}", info.name));
54            //         println!("Description: {}", info.description);
55            //         println!("Installed: {}", if info.installed { "Yes" } else { "No" });
56
57            //         if let Some(version) = &info.version {
58            //             println!("Version: {version}");
59            //         }
60
61            //         if let Some(homepage) = &info.homepage {
62            //             println!("Homepage: {homepage}");
63            //         }
64
65            //         println!(
66            //             "Auto-install: {}",
67            //             if info.supports_auto_install {
68            //                 "Yes"
69            //             } else {
70            //                 "No"
71            //             }
72            //         );
73            //     }
74            //     Err(e) => {
75            //         UI::error(&format!("Tool not found: {e}"));
76            //     }
77            // }
78        }
79
80        PluginCommand::Enable { name: _ } => {
81            UI::warning("Enable/disable commands not applicable to the new tool system");
82            UI::hint("All tools are automatically available");
83        }
84
85        PluginCommand::Disable { name: _ } => {
86            UI::warning("Enable/disable commands not applicable to the new tool system");
87            UI::hint("All tools are automatically available");
88        }
89
90        PluginCommand::Search { query } => {
91            UI::header(&format!("Tools matching '{query}'"));
92            UI::warning("Plugin search not yet implemented in new architecture");
93            // let tools = tool_manager.get_all_tools();
94            // let matching_tools: Vec<_> = tools
95            //     .into_iter()
96            //     .filter(|tool| {
97            //         tool.name.contains(&query)
98            //             || tool
99            //                 .description
100            //                 .to_lowercase()
101            //                 .contains(&query.to_lowercase())
102            //     })
103            //     .collect();
104
105            // if matching_tools.is_empty() {
106            //     UI::info(&format!("No tools found matching '{query}'"));
107            // } else {
108            //     UI::header(&format!("Tools matching '{query}'"));
109            //     for tool in matching_tools {
110            //         println!("  * {} - {}", tool.name, tool.description);
111            //     }
112            // }
113        }
114
115        PluginCommand::Stats => {
116            UI::header("Tool Statistics");
117            UI::warning("Plugin stats not yet implemented in new architecture");
118            // let tools = tool_manager.get_all_tools();
119            // let total = tools.len();
120            // let installed = tools.iter().filter(|t| t.installed).count();
121            // let auto_install = tools.iter().filter(|t| t.supports_auto_install).count();
122
123            // UI::header("Tool Statistics");
124            // println!("  Total tools: {total}");
125            // println!("  Installed tools: {installed}");
126            // println!("  Not installed: {}", total - installed);
127            // println!("  Support auto-install: {auto_install}");
128        }
129    }
130
131    Ok(())
132}