rush_sync_server/
lib.rs

1// =====================================================
2// FILE: src/lib.rs - CLEAN VERSION OHNE PERFORMANCE
3// =====================================================
4
5#[macro_export]
6macro_rules! impl_default {
7    ($type:ty, $body:expr) => {
8        impl Default for $type {
9            fn default() -> Self {
10                $body
11            }
12        }
13    };
14}
15
16#[macro_export]
17macro_rules! matches_exact {
18    ($cmd:expr, $($pattern:literal)|+) => {
19        matches!($cmd.trim().to_lowercase().as_str(), $($pattern)|+)
20    };
21}
22
23// Module definitions
24pub mod commands;
25pub mod core;
26pub mod i18n;
27pub mod input;
28pub mod output;
29pub mod server;
30pub mod setup;
31pub mod ui;
32
33// Essential re-exports
34pub use commands::{Command, CommandHandler, CommandRegistry};
35pub use core::config::Config;
36pub use core::error::{AppError, Result};
37
38pub fn create_default_registry() -> CommandRegistry {
39    use commands::{
40        cleanup::CleanupCommand, clear::ClearCommand, create::CreateCommand, exit::ExitCommand,
41        history::HistoryCommand, lang::LanguageCommand, list::ListCommand,
42        log_level::LogLevelCommand, restart::RestartCommand, start::StartCommand,
43        stop::StopCommand, theme::ThemeCommand, version::VersionCommand,
44    };
45
46    let mut registry = CommandRegistry::new();
47
48    // Core Commands
49    registry.register(VersionCommand);
50    registry.register(ClearCommand);
51    registry.register(ExitCommand);
52    registry.register(RestartCommand);
53
54    // Configuration Commands
55    registry.register(LogLevelCommand);
56    registry.register(LanguageCommand::new());
57    registry.register(ThemeCommand::new());
58
59    // Utility Commands
60    registry.register(HistoryCommand);
61
62    // Server
63    registry.register(CleanupCommand::new());
64    registry.register(CreateCommand::new());
65    registry.register(ListCommand::new());
66    registry.register(StartCommand::new());
67    registry.register(StopCommand::new());
68
69    registry.initialize();
70    registry
71}
72
73// Main entry point
74pub async fn run() -> Result<()> {
75    let config = Config::load().await?;
76    let mut screen = ui::screen::ScreenManager::new(&config).await?;
77    screen.run().await
78}
79
80pub use ui::screen::ScreenManager;
81
82// Convenience functions
83pub async fn run_with_config(config: Config) -> Result<()> {
84    let mut screen = ScreenManager::new(&config).await?;
85    screen.run().await
86}
87
88pub fn create_handler() -> CommandHandler {
89    CommandHandler::new()
90}
91
92pub async fn load_config() -> Result<Config> {
93    Config::load().await
94}