use getopts::Options;

/**
fn get_help(args: &Vec<String>, opts: &Options) -> String {
    return format!("Usage: {} -h? --help?", args[0]);
}
**/

fn main() {
    println!("Hello, world!");

    for (key,arg) in std::env::args_os().enumerate() {
        println!("[{}] Arg: {:?}", key, arg.to_str().expect("Arg should be serializable to string"));
    }

    let args: Vec<String> = std::env::args().collect();
    let mut opts = Options::new();
    opts.optflag("h", "help", "print this help");
    // let usage = get_help(&args, &opts);
    // opts.usage(&usage);

    let matches = match opts.parse(&args[1..]) {
        Ok(m) => { m }
        Err(f) => panic!("Got error: {}", f.to_string())
    };

    if matches.opt_present("h") {
        // println!(get_help(&args, &opts));
        let program = format!("{} [args]", args[0]);
        println!("Usage: {}", opts.usage(&program));
        return;
    }

    println!("Running...");


}
