'see underline code: can anyone please tell me why the "h" optsflag is not being recognised??
Code:
extern crate getopts;
use getopts::Options;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
println!("args {:?}", args); // ************ see output
let mut opts = Options::new();
opts.optflag("h", "help", "Show this usage message.");
let matches = match opts.parse(&args[1..]) {
Ok(m) => { m }
Err(e) => { panic!(e.to_string()) }
};
println!("matches {:?}", matches.free); // *********** see output
**if !matches.opt_present("h") {**
** println!("Not found"); // ******* see output**
** return;**
** }**
}
Output:
Finished dev [unoptimized + debuginfo] target(s) in 4.2 secs
Running target/debug/case_study ./uscitiespop.csv abbeabbeville h
args ["target/debug/case_study", "./uscitiespop.csv", "abbeabbeville", "h"]
matches ["./uscitiespop.csv", "abbeabbeville", "h"]
not found