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 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, theme::ThemeCommand,
41 version::VersionCommand,
42 };
43
44 let mut registry = CommandRegistry::new();
45
46 registry.register(VersionCommand);
48 registry.register(ClearCommand);
49 registry.register(ExitCommand);
50 registry.register(RestartCommand);
51
52 registry.register(LogLevelCommand);
54 registry.register(LanguageCommand::new());
55 registry.register(ThemeCommand::new());
56
57 registry.register(HistoryCommand);
59
60 registry.initialize();
61 registry
62}
63
64pub async fn run() -> Result<()> {
66 let config = Config::load().await?;
67 let mut screen = ui::screen::ScreenManager::new(&config).await?;
68 screen.run().await
69}
70
71pub use ui::screen::ScreenManager;
72
73pub async fn run_with_config(config: Config) -> Result<()> {
75 let mut screen = ScreenManager::new(&config).await?;
76 screen.run().await
77}
78
79pub fn create_handler() -> CommandHandler {
80 CommandHandler::new()
81}
82
83pub async fn load_config() -> Result<Config> {
84 Config::load().await
85}