Start adding Rust getopts
This commit is contained in:
parent
61a142d570
commit
2a91efd07f
@ -11,3 +11,4 @@ crate-type = ["staticlib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
getopts = "0.2"
|
||||||
|
17
src/lib.rs
17
src/lib.rs
@ -11,7 +11,7 @@ pub extern "C" fn print_usage(version_ptr: *const c_char) {
|
|||||||
|
|
||||||
let msg = r#"
|
let msg = r#"
|
||||||
Usage:
|
Usage:
|
||||||
dmrconfig -r [-t]\n
|
dmrconfig -r [-t]
|
||||||
Read codeplug from the radio to a file 'device.img'.
|
Read codeplug from the radio to a file 'device.img'.
|
||||||
Save configuration to a text file 'device.conf'.
|
Save configuration to a text file 'device.conf'.
|
||||||
dmrconfig -w [-t] file.img
|
dmrconfig -w [-t] file.img
|
||||||
@ -39,6 +39,21 @@ Options:
|
|||||||
std::process::exit(-1);
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user