feat(meta): version command
This commit is contained in:
parent
2dead7de0a
commit
315703d46b
5 changed files with 21 additions and 7 deletions
|
|
@ -10,6 +10,7 @@ select ::= "select"
|
|||
|
||||
meta-command ::= "." "exit"
|
||||
| "about"
|
||||
| "version"
|
||||
|
||||
int ::= sign? digit+
|
||||
sign ::= "+"
|
||||
|
|
|
|||
|
|
@ -226,8 +226,8 @@ i will use rustyline, since it seems like the most feature-complete
|
|||
|
||||
* DONE write a proper grammar
|
||||
|
||||
* TODO .about meta-command
|
||||
* TODO .version meta-command
|
||||
* DONE .about meta-command
|
||||
* DONE .version meta-command
|
||||
* TODO .license meta-command
|
||||
* TODO .help meta-command
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,18 @@ pub fn startup_msg() -> String {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn about_msg() -> String {
|
||||
pub fn version_msg() -> String {
|
||||
let name = env!("CARGO_PKG_NAME");
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
|
||||
format!("{name} v{version}")
|
||||
}
|
||||
|
||||
pub fn about_msg() -> String {
|
||||
let version = version_msg();
|
||||
|
||||
format!(
|
||||
"{name} v{version} -- A database engine\n\
|
||||
"{version} -- A database engine\n\
|
||||
Note: This is experimental software. No maintenance is intendend."
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use crate::branding;
|
|||
pub enum MetaCommand {
|
||||
Exit,
|
||||
About,
|
||||
Version,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for MetaCommand {
|
||||
|
|
@ -11,6 +12,7 @@ impl std::fmt::Display for MetaCommand {
|
|||
match self {
|
||||
MetaCommand::Exit => write!(f, "exit"),
|
||||
MetaCommand::About => write!(f, "about"),
|
||||
MetaCommand::Version => write!(f, "version"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,9 +26,13 @@ impl MetaCommand {
|
|||
match self {
|
||||
MetaCommand::Exit => MetaCommandExecuteResult { should_exit: true },
|
||||
MetaCommand::About => {
|
||||
print!("{}", branding::about_msg());
|
||||
MetaCommandExecuteResult { should_exit: false }
|
||||
}
|
||||
print!("{}", branding::about_msg());
|
||||
MetaCommandExecuteResult { should_exit: false }
|
||||
}
|
||||
MetaCommand::Version => {
|
||||
print!("{}", branding::version_msg());
|
||||
MetaCommandExecuteResult { should_exit: false }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ impl Tokenizer {
|
|||
match word.to_lowercase().as_str() {
|
||||
".exit" => Some(TokenData::MetaCommand(MetaCommand::Exit)),
|
||||
".about" => Some(TokenData::MetaCommand(MetaCommand::About)),
|
||||
".version" => Some(TokenData::MetaCommand(MetaCommand::Version)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue