Added command-line argument parsing

pull/2/head
Mark 2023-06-07 15:21:48 -07:00
parent dae76f3d56
commit fe58addcc2
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,7 @@
use std::io::Write;
use std::io::stdout;
use std::io::stdin;
use std::env;
use termion::{
event::Key,
@ -120,6 +121,18 @@ fn do_expression(
pub fn main() -> Result<(), std::io::Error> {
let mut stdout = stdout().into_raw_mode().unwrap();
let args: Vec<String> = env::args().collect();
// Handle command-line arguments
if args.iter().any(|s| s == "--help") {
command::do_command(&mut stdout, &String::from("help"))?;
return Ok(());
} else if args.iter().any(|s| s == "--version") {
write!(stdout, "Daisy v{}\r\n", env!("CARGO_PKG_VERSION"))?;
return Ok(());
}
//let size = termion::terminal_size().unwrap();
//write!(stdout, "{:?}", size).unwrap();