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