diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 87dd041..1ec5174 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -use std::env; +extern crate clap; + use std::fs; use std::io; use std::io::prelude::*; @@ -45,13 +46,35 @@ fn cli_controller(asyncpair: Arc<(Mutex<bool>, Condvar)>) { } fn main() { - let args: Vec<_> = env::args().collect(); - if args.len() < 2 { - println!("Please, specify ihex file"); - return; - } + let cli_args_matches = clap::App::new("x51emu") + .version("0.1.0") + .author("oxore") + .about("MCS51 emulator") + .arg( + clap::Arg::with_name("file") + .short("f") + .long("file") + .value_name("FILE") + .help("Sets a file with program to load") + .takes_value(true) + .required(true), + ) + .arg( + clap::Arg::with_name("interface") + .short("i") + .long("interface") + .value_name("INTERFACE") + .help("Sets a controlling and I/O interface") + .takes_value(true) + .possible_values(&["cli", "ws"]), + ) + .get_matches(); + + let filename = cli_args_matches + .value_of("file") + .expect("No file name provided"); let data = - fs::read_to_string(&args[1]).unwrap_or_else(|_| panic!("Unable to read file {}", &args[1])); + fs::read_to_string(filename).unwrap_or_else(|_| panic!("Unable to read file {}", filename)); let asyncpair = Arc::new((Mutex::new(false), Condvar::new())); let asyncpair2 = asyncpair.clone(); |