1#[macro_export]
7macro_rules! impl_default {
8 ($type:ty, $body:expr) => {
9 impl Default for $type {
10 fn default() -> Self {
11 $body
12 }
13 }
14 };
15}
16
17#[macro_export]
18macro_rules! matches_exact {
19 ($cmd:expr, $($pattern:literal)|+) => {
20 matches!($cmd.trim().to_lowercase().as_str(), $($pattern)|+)
21 };
22}
23
24#[macro_export]
26macro_rules! register_command {
27 ($registry:expr, $command:expr) => {
28 $registry.register($command);
29 };
30}
31
32#[macro_export]
33macro_rules! register_commands {
34 ($registry:expr, $($command:expr),+ $(,)?) => {
35 $(
36 $crate::register_command!($registry, $command);
37 )+
38 };
39}
40
41#[macro_export]
43macro_rules! create_full_registry {
44 () => {{
45 use $crate::commands::{
46 clear::ClearCommand, exit::exit::ExitCommand, history::HistoryCommand,
47 lang::LanguageCommand, restart::RestartCommand, version::VersionCommand,
48 };
49
50 let mut registry = $crate::commands::registry::CommandRegistry::new();
51
52 $crate::register_commands!(
53 registry,
54 HistoryCommand,
55 ExitCommand,
56 LanguageCommand,
57 ClearCommand,
58 RestartCommand,
59 VersionCommand
60 );
61
62 registry.initialize();
63 registry
64 }};
65}
66
67#[macro_export]
69macro_rules! create_registry_with_plugins {
70 ($($plugin:expr),+ $(,)?) => {{
71 let mut registry = create_full_registry!();
72 let mut plugin_manager = $crate::commands::PluginManager::new();
73
74 $(
75 plugin_manager.load_plugin($plugin);
76 )+
77
78 plugin_manager.apply_to_registry(&mut registry);
79 (registry, plugin_manager)
80 }};
81}
82
83pub mod commands;
85pub mod core;
86pub mod i18n;
87pub mod input;
88pub mod output;
89pub mod setup;
90pub mod ui;
91
92pub use commands::{Command, CommandHandler, CommandPlugin, CommandRegistry, PluginManager};
94pub use core::config::Config;
95pub use core::error::{AppError, Result};
96
97pub fn create_default_registry() -> CommandRegistry {
99 use commands::{
100 clear::ClearCommand, exit::exit::ExitCommand, history::HistoryCommand,
101 lang::LanguageCommand, log_level::LogLevelCommand, performance::PerformanceCommand,
102 restart::RestartCommand, version::VersionCommand,
103 };
104
105 let mut registry = CommandRegistry::new();
106
107 registry.register(HistoryCommand);
108 registry.register(ExitCommand);
109 registry.register(LogLevelCommand);
110 registry.register(LanguageCommand);
111 registry.register(ClearCommand);
112 registry.register(RestartCommand);
113 registry.register(VersionCommand);
114 registry.register(PerformanceCommand); registry.initialize();
117 registry
118}
119
120pub async fn run() -> Result<()> {
122 let config = Config::load().await?;
123 let mut screen = ui::screen::ScreenManager::new(&config).await?;
124 screen.run().await
125}