1#[macro_export]
2macro_rules! impl_default {
3 ($type:ty, $body:expr) => {
4 impl Default for $type {
5 fn default() -> Self {
6 $body
7 }
8 }
9 };
10}
11
12#[macro_export]
13macro_rules! matches_exact {
14 ($cmd:expr, $($pattern:literal)|+) => {
15 matches!($cmd.trim().to_lowercase().as_str(), $($pattern)|+)
16 };
17}
18
19pub mod commands;
21pub mod core;
22pub mod i18n;
23pub mod input;
24pub mod output;
25pub mod setup;
26pub mod ui;
27
28pub use commands::{Command, CommandHandler, CommandRegistry};
30pub use core::config::Config;
31pub use core::error::{AppError, Result};
32
33pub fn create_default_registry() -> CommandRegistry {
34 use commands::{
35 clear::ClearCommand, exit::exit::ExitCommand, history::HistoryCommand,
36 lang::LanguageCommand, log_level::LogLevelCommand, performance::PerformanceCommand,
37 restart::RestartCommand, theme::ThemeCommand, version::VersionCommand,
38 };
39
40 let mut registry = CommandRegistry::new();
41
42 registry.register(HistoryCommand);
43 registry.register(ExitCommand);
44 registry.register(LogLevelCommand);
45 registry.register(LanguageCommand::new());
46 registry.register(ClearCommand);
47 registry.register(RestartCommand);
48 registry.register(VersionCommand);
49 registry.register(PerformanceCommand);
50 registry.register(ThemeCommand::new());
51
52 registry.initialize();
53 registry
54}
55
56pub async fn run() -> Result<()> {
58 let config = Config::load().await?;
59 let mut screen = ui::screen::ScreenManager::new(&config).await?;
60 screen.run().await
61}
62
63pub use ui::screen::ScreenManager;
64
65pub async fn run_with_config(config: Config) -> Result<()> {
67 let mut screen = ScreenManager::new(&config).await?;
68 screen.run().await
69}
70
71pub fn create_handler() -> CommandHandler {
72 CommandHandler::new()
73}
74
75pub async fn load_config() -> Result<Config> {
76 Config::load().await
77}