use crate::app::App;
pub type CommandHandler = fn(&mut App, &[String]);
pub struct CommandDef {
pub handler: CommandHandler,
pub description: &'static str,
pub aliases: &'static [&'static str],
pub category: CommandCategory,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum CommandCategory {
Connection,
Channel,
Messaging,
Configuration,
Info,
Other,
}
impl CommandCategory {
pub const fn label(self) -> &'static str {
match self {
Self::Connection => "Connection",
Self::Channel => "Channel",
Self::Messaging => "Messaging",
Self::Configuration => "Configuration",
Self::Info => "Info",
Self::Other => "Other",
}
}
}
pub const CATEGORY_ORDER: &[CommandCategory] = &[
CommandCategory::Connection,
CommandCategory::Channel,
CommandCategory::Messaging,
CommandCategory::Configuration,
CommandCategory::Info,
CommandCategory::Other,
];
pub const C_HEADER: &str = "%Z7aa2f7"; pub const C_CMD: &str = "%Zc0caf5"; pub const C_DIM: &str = "%Z565f89"; pub const C_TEXT: &str = "%Za9b1d6"; pub const C_OK: &str = "%Z9ece6a"; pub const C_ERR: &str = "%Zf7768e"; pub const C_RST: &str = "%N";
pub fn divider(title: &str) -> String {
let pad = 45usize.saturating_sub(title.len() + 7);
format!("{C_HEADER}───── {title} {}{C_RST}", "─".repeat(pad))
}