Implements the parse_insert_command function to handle the insert statement according to the grammar definition. The function now correctly parses the command format insert int string string and creates a structured Statement::Insert with the id, username, and email fields.
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use crate::branding;
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
pub enum MetaCommand {
|
|
Exit,
|
|
About,
|
|
Version,
|
|
}
|
|
|
|
impl std::fmt::Display for MetaCommand {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
match self {
|
|
MetaCommand::Exit => write!(f, "exit"),
|
|
MetaCommand::About => write!(f, "about"),
|
|
MetaCommand::Version => write!(f, "version"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct MetaCommandExecuteResult {
|
|
pub should_exit: bool,
|
|
}
|
|
|
|
impl MetaCommand {
|
|
pub fn execute(&self) -> MetaCommandExecuteResult {
|
|
match self {
|
|
MetaCommand::Exit => MetaCommandExecuteResult { should_exit: true },
|
|
MetaCommand::About => {
|
|
print!("{}", branding::about_msg());
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
}
|
|
MetaCommand::Version => {
|
|
print!("{}", branding::version_msg());
|
|
MetaCommandExecuteResult { should_exit: false }
|
|
}
|
|
}
|
|
}
|
|
}
|