Start adding Rust getopts

This commit is contained in:
Greg Shuflin 2021-02-27 22:52:27 -08:00
parent 61a142d570
commit 2a91efd07f
3 changed files with 18 additions and 2 deletions

View File

@ -11,3 +11,4 @@ crate-type = ["staticlib"]
[dependencies]
libc = "0.2"
getopts = "0.2"

2
main.c
View File

@ -59,7 +59,7 @@ int main(int argc, char **argv)
case 'c': ++config_flag; continue;
case 'u': ++csv_flag; continue;
case 'l': ++list_flag; continue;
case 'v': ++verify_flag; continue;
case 'v': ++verify_flag; continue;
default:
usage();
case EOF:

View File

@ -11,7 +11,7 @@ pub extern "C" fn print_usage(version_ptr: *const c_char) {
let msg = r#"
Usage:
dmrconfig -r [-t]\n
dmrconfig -r [-t]
Read codeplug from the radio to a file 'device.img'.
Save configuration to a text file 'device.conf'.
dmrconfig -w [-t] file.img
@ -39,6 +39,21 @@ Options:
std::process::exit(-1);
}
#[no_mangle]
pub extern "C" fn process_options() {
use getopts::Options;
let mut opts = Options::new();
opts.optflag("t", "", "Trace USB protocol.");
opts.optflag("r", "", "Read codeplug from the radio to a file 'device.img'.\nSave configuration to a text file 'device.conf'.");
opts.optflag("w", "", "Write codeplug to the radio.");
opts.optflag("c", "", "Verify configuration script for the radio.");
opts.optflag("u", "", "Update contacts database from CSV file.");
opts.optflag("l", "", "List all supported radios.");
opts.optflag("v", "", "Verify configuration script for the radio.");
}
#[cfg(test)]
mod tests {
#[test]