diff --git a/src/bin/code_gen.rs b/src/bin/code_gen.rs index 0657048..040a79a 100644 --- a/src/bin/code_gen.rs +++ b/src/bin/code_gen.rs @@ -53,7 +53,7 @@ impl FromStr for RadiusAttributeValueType { } fn print_usage(program: &str, opts: &Options) { - let brief = format!("Usage: {} FILE [options]", program); + let brief = format!("Usage: {} [options] DICT_FILE OUT_FILE", program); print!("{}", opts.usage(&brief)); process::exit(0); } @@ -68,13 +68,18 @@ where fn main() { let args: Vec = env::args().collect(); - let _program = args[0].clone(); + let program = args[0].clone(); - let opts = Options::new(); + let mut opts = Options::new(); + opts.optflag("h", "help", "print this help menu"); let matches = opts .parse(&args[1..]) .unwrap_or_else(|f| panic!(f.to_string())); + if matches.opt_present("h") { + print_usage(&program, &opts); + } + let dict_file_path = Path::new(&matches.free[0]); if !dict_file_path.exists() { panic!("no such dictionary file => {}", &matches.free[0]);