1#[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
23pub mod commands;
25pub mod core;
26pub mod i18n;
27pub mod input;
28pub mod output;
29pub mod setup;
30pub mod ui;
31
32pub mod server;
34
35pub use commands::{Command, CommandHandler, CommandRegistry};
37pub use core::config::Config;
38pub use core::error::{AppError, Result};
39
40pub use server::{ServerConfig, ServerInfo, ServerInstance, ServerManager, ServerMode};
42
43use server::ServerManager as InternalServerManager;
45
46pub fn create_default_registry() -> CommandRegistry {
47 use commands::{
48 clear::ClearCommand,
49 exit::exit::ExitCommand,
50 history::HistoryCommand,
51 lang::LanguageCommand,
52 log_level::LogLevelCommand,
53 performance::PerformanceCommand,
54 restart::RestartCommand,
55 server::ServerCommand, theme::ThemeCommand,
57 version::VersionCommand,
58 };
59
60 let mut registry = CommandRegistry::new();
61
62 registry.register(HistoryCommand);
64 registry.register(ExitCommand);
65 registry.register(LogLevelCommand);
66 registry.register(LanguageCommand::new());
67 registry.register(ClearCommand);
68 registry.register(RestartCommand);
69 registry.register(VersionCommand);
70 registry.register(PerformanceCommand);
71 registry.register(ThemeCommand::new());
72
73 registry.register(ServerCommand);
75
76 registry.initialize();
77 registry
78}
79
80pub async fn run() -> Result<()> {
82 let config = Config::load().await?;
83 let mut screen = ui::screen::ScreenManager::new(&config).await?;
84 screen.run().await
85}
86
87pub use ui::screen::ScreenManager;
88
89pub async fn run_with_config(config: Config) -> Result<()> {
91 let mut screen = ScreenManager::new(&config).await?;
92 screen.run().await
93}
94
95pub fn create_handler() -> CommandHandler {
96 CommandHandler::new()
97}
98
99pub async fn load_config() -> Result<Config> {
100 Config::load().await
101}
102
103pub async fn create_server_manager() -> InternalServerManager {
105 InternalServerManager::new()
106}
107
108pub async fn start_server_management() -> Result<InternalServerManager> {
109 let manager = InternalServerManager::new();
110 manager.load_servers().await?;
111 Ok(manager)
112}