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 setup;
30pub mod ui;
31
32// Essential re-exports
33pub use commands::{Command, CommandHandler, CommandRegistry};
34pub use core::config::Config;
35pub use core::error::{AppError, Result};
36
37pub fn create_default_registry() -> CommandRegistry {
38    use commands::{
39        clear::ClearCommand, exit::ExitCommand, history::HistoryCommand, lang::LanguageCommand,
40        log_level::LogLevelCommand, restart::RestartCommand, test::TestCommand,
41        theme::ThemeCommand, version::VersionCommand,
42    };
43
44    let mut registry = CommandRegistry::new();
45
46    // Core Commands
47    registry.register(VersionCommand);
48    registry.register(ClearCommand);
49    registry.register(ExitCommand);
50    registry.register(RestartCommand);
51
52    // Configuration Commands
53    registry.register(LogLevelCommand);
54    registry.register(LanguageCommand::new());
55    registry.register(ThemeCommand::new());
56
57    // Utility Commands
58    registry.register(HistoryCommand);
59    registry.register(TestCommand);
60
61    registry.initialize();
62    registry
63}
64
65// Main entry point
66pub async fn run() -> Result<()> {
67    let config = Config::load().await?;
68    let mut screen = ui::screen::ScreenManager::new(&config).await?;
69    screen.run().await
70}
71
72pub use ui::screen::ScreenManager;
73
74// Convenience functions
75pub async fn run_with_config(config: Config) -> Result<()> {
76    let mut screen = ScreenManager::new(&config).await?;
77    screen.run().await
78}
79
80pub fn create_handler() -> CommandHandler {
81    CommandHandler::new()
82}
83
84pub async fn load_config() -> Result<Config> {
85    Config::load().await
86}