Argonaut
An argument parser for Rust, that grants as much control over the parser as possible.
Argument conversion
This means that the arguments are not converted to other types (except for switches that are boolean by default).
Help messages
It also means that help messages are not handled either. Just write it yourself, and make it NICE!
Error handling
The actual argument parsing returns errors that should be pretty simple to convey to users, but these are not handled by the parser either.
Adding arguments to the parser and accessing arguments on the parsed arguments will only return an error string, as they may only have logical errors, such as adding arguments that would overwrite each other, or trying to access a parsed argument using an invalid identifier.
Example
This can be found in examples/main.rs as well, and be run with cargo run --example main -- foo bar -x baz --verbose -e extra1 extra2 --add a b c
.
You can also try running it without the arguments, but these arguments will make the parse succeed.
extern crate argonaut;
use ;
use ;
use env;
Terminology
Flag: The identifying token for an argument (--flag) Switch: A flag with no arguments that is either there or not there Parameter: Tokens following an argument. Trail: Zero or more tokens that follow the required positional arguments.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.