Crates.io | getopt3 |
lib.rs | getopt3 |
version | 2.1.0 |
source | src |
created_at | 2023-03-24 17:59:21.846198 |
updated_at | 2024-07-08 19:38:24.172346 |
description | Zero dependency command line argument parser |
homepage | https://gitlab.com/hsn10/getopt3 |
repository | https://gitlab.com/hsn10/getopt3.git |
max_upload_size | |
id | 819587 |
size | 36,818 |
Version 2.1.0 MIT Licensed
unsafe
Rust.no_std
Rust version in development.let g = getopt3::new(arguments, optstring)
getopt3::new constructor arguments:
std::env::args()
but you need to skip first
argument because its executable name. It can be done manually or by calling hideBin
.Returned value:
getopt structure returned by constructor has following members:
You can run strictness check by calling validate(getopt) function. This function returns back Result with supplied getopt instance or error as String. It can detect if unknown options are encountered or required argument is missing and signal error.
use std::env::args;
use getopt3::hideBin;
let rc = getopt3::new(hideBin(args()), "ab:c");
if let Ok(g) = rc {
// command line options parsed sucessfully
if let Some(arg) = g.options.get(&'b') {
// handle b argument stored in arg
};
};