Show usage for code_gen

This commit is contained in:
moznion
2020-11-28 17:35:56 +09:00
parent 5864b003e2
commit 869c7cb98b

View File

@@ -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<String> = 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]);