6 releases
0.1.5 | Apr 14, 2021 |
---|---|
0.1.4 | Apr 13, 2021 |
#3 in #commands
770KB
125 lines
Contains (WOFF font, 190KB) doc/FiraSans-Medium.woff, (WOFF font, 185KB) doc/FiraSans-Regular.woff, (WOFF font, 94KB) doc/SourceSerifPro-Bold.ttf.woff, (WOFF font, 89KB) doc/SourceSerifPro-Regular.ttf.woff, (WOFF font, 56KB) doc/SourceCodePro-Regular.woff, (WOFF font, 56KB) doc/SourceCodePro-Semibold.woff and 1 more.
Docs
optparse
License
This project is licensed under GPLv3.
Installation
Add optparse to your Project by downloading it from crates.io or simply adding it to your dependencies:
[dependencies]
optparse = ["0.1.0"]
Documentation
The documentation can be found here.
Usage
// import the crate
use optparse;
// functions/closures must take String as their only parameter
// and not return anything
fn hello(arg: String) {
println!("Hello {} \\o/", arg);
}
fn main() {
// create a new parser with a parser description
let mut parser = optparse::Parser::new("Example Description");
// register a flag and a corresponding function to be called
// from the command line
// register!(flag, command description, function/closure, parser);
optparse::register!("-welcome", "Example Description", hello, parser);
// run the parser using the arguments from std::env
// parse!(arguments, arguments length, parser)
let args: Vec<String> = std::env::args().collect();
optparse::parse!(args.clone(), args.len() as u8, parser);
}
Work in Progress
- aliasing
- single flag parsing
- multi parameter closures
You want to contribute? Feel free to leave a comment or create a pull request.