mirror of https://github.com/rm-dr/daisy
Added command-line argument parsing
parent
dae76f3d56
commit
fe58addcc2
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue