rush_sync_server/
lib.rs

1// =====================================================
2// FILE: src/lib.rs - PERFORMANCE COMMAND HINZUGEFÜGT
3// =====================================================
4
5// ✅ ALTE Macros (behalten für Kompatibilität)
6#[macro_export]
7macro_rules! impl_default {
8    ($type:ty, $body:expr) => {
9        impl Default for $type {
10            fn default() -> Self {
11                $body
12            }
13        }
14    };
15}
16
17#[macro_export]
18macro_rules! matches_exact {
19    ($cmd:expr, $($pattern:literal)|+) => {
20        matches!($cmd.trim().to_lowercase().as_str(), $($pattern)|+)
21    };
22}
23
24// ✅ NEUE Macros für Command System
25#[macro_export]
26macro_rules! register_command {
27    ($registry:expr, $command:expr) => {
28        $registry.register($command);
29    };
30}
31
32#[macro_export]
33macro_rules! register_commands {
34    ($registry:expr, $($command:expr),+ $(,)?) => {
35        $(
36            $crate::register_command!($registry, $command);
37        )+
38    };
39}
40
41/// ✅ HAUPTMACRO - Erstellt vollständige Registry mit allen Standard-Commands
42#[macro_export]
43macro_rules! create_full_registry {
44    () => {{
45        use $crate::commands::{
46            clear::ClearCommand,
47            exit::exit::ExitCommand,
48            history::HistoryCommand,
49            lang::LanguageCommand,
50            restart::RestartCommand,
51            theme::ThemeCommand, // ✅ NEU HINZUGEFÜGT
52            version::VersionCommand,
53        };
54
55        let mut registry = $crate::commands::registry::CommandRegistry::new();
56
57        $crate::register_commands!(
58            registry,
59            HistoryCommand,
60            ExitCommand,
61            LanguageCommand,
62            ClearCommand,
63            RestartCommand,
64            VersionCommand,
65            ThemeCommand // ✅ NEU HINZUGEFÜGT
66        );
67
68        registry.initialize();
69        registry
70    }};
71}
72
73/// ✅ ERWEITERT - Registry mit Plugins
74#[macro_export]
75macro_rules! create_registry_with_plugins {
76    ($($plugin:expr),+ $(,)?) => {{
77        let mut registry = create_full_registry!();
78        let mut plugin_manager = $crate::commands::PluginManager::new();
79
80        $(
81            plugin_manager.load_plugin($plugin);
82        )+
83
84        plugin_manager.apply_to_registry(&mut registry);
85        (registry, plugin_manager)
86    }};
87}
88
89// Module definitions
90pub mod commands;
91pub mod core;
92pub mod i18n;
93pub mod input;
94pub mod output;
95pub mod setup;
96pub mod ui;
97
98// Essential re-exports
99pub use commands::{Command, CommandHandler, CommandPlugin, CommandRegistry, PluginManager};
100pub use core::config::Config;
101pub use core::error::{AppError, Result};
102
103pub fn create_default_registry() -> CommandRegistry {
104    use commands::{
105        clear::ClearCommand, exit::exit::ExitCommand, history::HistoryCommand,
106        lang::LanguageCommand, log_level::LogLevelCommand, performance::PerformanceCommand,
107        restart::RestartCommand, theme::ThemeCommand, version::VersionCommand,
108    };
109
110    let mut registry = CommandRegistry::new();
111
112    registry.register(HistoryCommand);
113    registry.register(ExitCommand);
114    registry.register(LogLevelCommand);
115    registry.register(LanguageCommand::new()); // ✅ GEÄNDERT: ::new() hinzugefügt
116    registry.register(ClearCommand);
117    registry.register(RestartCommand);
118    registry.register(VersionCommand);
119    registry.register(PerformanceCommand);
120    registry.register(ThemeCommand::new()); // ✅ GEÄNDERT: ::new() hinzugefügt
121
122    registry.initialize();
123    registry
124}
125
126// ✅ MAIN ENTRY POINT - für external usage
127pub async fn run() -> Result<()> {
128    let config = Config::load().await?;
129    let mut screen = ui::screen::ScreenManager::new(&config).await?;
130    screen.run().await
131}
132
133/// ✅ PUBLIC API
134pub use ui::screen::ScreenManager;
135
136// ✅ CONVENIENCE FUNCTIONS
137pub async fn run_with_config(config: Config) -> Result<()> {
138    let mut screen = ScreenManager::new(&config).await?;
139    screen.run().await
140}
141
142pub fn create_handler() -> CommandHandler {
143    CommandHandler::new()
144}
145
146pub async fn load_config() -> Result<Config> {
147    Config::load().await
148}