osdb/src/meta_commands.rs

39 lines
1 KiB
Rust
Raw Normal View History

2025-05-30 15:48:02 +02:00
use crate::branding;
#[derive(Debug, Eq, PartialEq)]
pub enum MetaCommand {
Exit,
2025-05-30 15:48:02 +02:00
About,
2025-05-31 15:59:58 +02:00
Version,
}
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
}
}
}
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 15:59:58 +02:00
print!("{}", branding::about_msg());
MetaCommandExecuteResult { should_exit: false }
}
MetaCommand::Version => {
print!("{}", branding::version_msg());
MetaCommandExecuteResult { should_exit: false }
},
}
}
}