# easy-args
A Rust library for simple and lightweight command-line argument parsing, with:
- Easy to use declarative usage via `ArgSpec`,
- Zero dependenies with other crates,
It's also worth pointing out what `easy-args` *is not*:
- Extensive. Only supports boolean flags, signed and unsigned 64-bit integers
and strings.
- Fast. By no means is it super slow but it hasn't been made with maximum
performance in mind.
Documentation:
- [API reference (docs.rs)](https://docs.rs/easy-args)
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
easy-args = "0.1.1"
```
To get started using easy-args.
First you must define an `ArgSpec` which will determine what the command-line
arguments are for your program and will be used by the parser to do some
simple checks.
You make an `ArgSpec` with the builder pattern.
```
let arg_spec = ArgSpec::build()
.boolean("windowed")
.string("mode")
.done();
```
Second you call `ArgSpecs`'s `parse()` method to retrieve the command-line
arguments in a processed form.
```
let args = arg_spec.parse()?;
if let Some(_) = args.boolean("windowed") {
// Put application into windowed mode
}
```
And that's it! The arguments have been parsed and processed and can be
accessed via `Args`'s getter methods.
`ArgSpec` also has a `parse()` method so you don't have to make a
throwaway variable.
```
let args = ArgSpec::build()
.boolean("windowed")
.string("mode")
.parse()?;
```
## Versions
easy-args is an immature crate and as such may make breaking changes in future
versions.
Current easy-args versions are:
- Version 0.1.0 was released in June 2021, with the very first implementation.
- Version 0.1.1 was released a few hours afterwards to add documentation.
# License
easy-args is distributed under the terms of the MIT license.
See [LICENSE-MIT](LICENSE-MIT) for details.