vx_tool_uv/
uv_plugin.rs

1//! UV plugin implementation
2
3use crate::uv_tool::{UvCommand, UvxTool};
4use vx_plugin::{VxPlugin, VxTool};
5
6/// UV plugin that manages UV-related tools
7#[derive(Debug)]
8pub struct UvPlugin;
9
10impl UvPlugin {
11    pub fn new() -> Self {
12        Self
13    }
14}
15
16#[async_trait::async_trait]
17impl VxPlugin for UvPlugin {
18    fn name(&self) -> &str {
19        "uv"
20    }
21
22    fn description(&self) -> &str {
23        "UV Python package management tools"
24    }
25
26    fn version(&self) -> &str {
27        "1.0.0"
28    }
29
30    fn tools(&self) -> Vec<Box<dyn VxTool>> {
31        vec![Box::new(UvCommand::new()), Box::new(UvxTool::new())]
32    }
33
34    fn supports_tool(&self, tool_name: &str) -> bool {
35        matches!(tool_name, "uv" | "uvx")
36    }
37}
38
39impl Default for UvPlugin {
40    fn default() -> Self {
41        Self::new()
42    }
43}
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_uv_plugin_creation() {
51        let plugin = UvPlugin::new();
52        assert_eq!(plugin.name(), "uv");
53        assert!(!plugin.description().is_empty());
54        assert!(!plugin.version().is_empty());
55    }
56
57    #[test]
58    fn test_uv_plugin_tools() {
59        let plugin = UvPlugin::new();
60        let tools = plugin.tools();
61
62        assert_eq!(tools.len(), 2);
63        assert!(tools.iter().any(|t| t.name() == "uv"));
64        assert!(tools.iter().any(|t| t.name() == "uvx"));
65    }
66
67    #[test]
68    fn test_uv_plugin_supports_tool() {
69        let plugin = UvPlugin::new();
70
71        assert!(plugin.supports_tool("uv"));
72        assert!(plugin.supports_tool("uvx"));
73        assert!(!plugin.supports_tool("nonexistent"));
74    }
75}