2025-05-30 15:48:02 +02:00
|
|
|
use crate::branding;
|
|
|
|
|
|
2025-05-04 12:06:47 +02:00
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
2025-05-02 20:35:45 +02:00
|
|
|
pub enum MetaCommand {
|
|
|
|
|
Exit,
|
2025-05-30 15:48:02 +02:00
|
|
|
About,
|
2025-05-31 15:59:58 +02:00
|
|
|
Version,
|
2025-05-02 20:35:45 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-10 10:55:44 +02:00
|
|
|
impl std::fmt::Display for MetaCommand {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
|
match self {
|
|
|
|
|
MetaCommand::Exit => write!(f, "exit"),
|
2025-05-30 15:48:02 +02:00
|
|
|
MetaCommand::About => write!(f, "about"),
|
2025-05-31 15:59:58 +02:00
|
|
|
MetaCommand::Version => write!(f, "version"),
|
2025-05-10 10:55:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-02 20:46:08 +02:00
|
|
|
pub struct MetaCommandExecuteResult {
|
|
|
|
|
pub should_exit: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl MetaCommand {
|
|
|
|
|
pub fn execute(&self) -> MetaCommandExecuteResult {
|
|
|
|
|
match self {
|
|
|
|
|
MetaCommand::Exit => MetaCommandExecuteResult { should_exit: true },
|
2025-05-30 15:48:02 +02:00
|
|
|
MetaCommand::About => {
|
2025-05-31 16:08:42 +02:00
|
|
|
print!("{}", branding::about_msg());
|
|
|
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
|
|
|
}
|
2025-05-31 15:59:58 +02:00
|
|
|
MetaCommand::Version => {
|
|
|
|
|
print!("{}", branding::version_msg());
|
2025-05-31 16:08:42 +02:00
|
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
|
|
|
}
|
2025-05-02 20:46:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|