More options logic
This commit is contained in:
parent
1c81834b62
commit
d41d257650
2
main.c
2
main.c
@ -80,11 +80,11 @@ int old_c_main(int argc, char **argv)
|
||||
radio_list();
|
||||
exit(0);
|
||||
}
|
||||
*/
|
||||
if (read_flag + write_flag + config_flag + csv_flag + verify_flag > 1) {
|
||||
fprintf(stderr, "Only one of -r, -w, -c, -v or -u options is allowed.\n");
|
||||
usage();
|
||||
}
|
||||
*/
|
||||
setvbuf(stdout, 0, _IOLBF, 0);
|
||||
setvbuf(stderr, 0, _IOLBF, 0);
|
||||
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -72,11 +72,23 @@ pub extern "C" fn rust_main(argc: c_int, argv: *const *const c_char) -> c_int {
|
||||
};
|
||||
|
||||
let list_flag = matches.opt_present("l");
|
||||
let verify_flag = matches.opt_present("v");
|
||||
let read_flag = matches.opt_present("r");
|
||||
let write_flag = matches.opt_present("w");
|
||||
let config_flag = matches.opt_present("c");
|
||||
let csv_flag = matches.opt_present("u");
|
||||
|
||||
if list_flag {
|
||||
radio::list();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if [read_flag, write_flag, config_flag, csv_flag, verify_flag].iter().filter(|x| **x).count() > 1 {
|
||||
eprintln!("Only one of -r, -w, -c, -v or -u options is allowed.");
|
||||
exit(-1);
|
||||
//print_usage();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
old_c_main(argc, argv)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user