Argonaut
A minimal argument parser for Rust.
Argument conversion
This means that the arguments are not converted to other types.
Help messages
It also means that help messages are not handled either. There used to be an optional generator of help messages, but it is broken at the moment.
Error handling
Errors are returned during the parse, so that the user may handle them explicitly. There is also small validation step when adding definitions for expected arguments, but just to ensure that they are logically sound.
Example
This can be found in examples/main.rs as well, and be run with
cargo run --example main -- foo bar -x baz --verbose -- arg --help
.
You can also try running it without the arguments, but these arguments will make the parse succeed.
extern crate argonaut;
use env;
use ;
const USAGE: &'static str = "Usage: cargo run --example main -- \
[--help | OPTIONS ] foo [foobar, ...]";
const HELP: &'static str = "\
Required arguments:
foo A single positional argument.
foobar [foobar ...] One or more trailing arguments.
Optional arguments:
--help | -h Show this message.
--version Show the version of this library.
--verbose | -v Set the 'verbose' flag to true.
--exclude | -x ARG Do something with a single parameter.
-- Collect all following arguments verbatim.\
";
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.