getopt3 - cli parser with GNU extension for Rust
================================================
*Version 2.0.1* [MIT Licensed](https://spdx.org/licenses/MIT.html)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
[![Crates.io](https://img.shields.io/crates/v/getopt3.svg)](https://crates.io/crates/getopt3)
[![dependency status](https://deps.rs/repo/gitlab/hsn10/getopt3/status.svg)](https://deps.rs/repo/gitlab/hsn10/getopt3)
[![Documentation](https://docs.rs/getopt3/badge.svg)](https://docs.rs/getopt3)
[![Downloads](https://img.shields.io/crates/d/getopt3)](https://crates.io/crates/getopt3/versions)
[![Gitlab pipeline status](https://gitlab.com/hsn10/getopt3/badges/master/pipeline.svg)](https://gitlab.com/hsn10/getopt3/commits/master)
[![](https://tokei.rs/b1/gitlab/hsn10/getopt3?category=code)](https://github.com/XAMPPRocky/tokei)

Features
--------

1. Rust port of well tested Scala code
1. GNU argument parsing rules. Options can be anywhere in command line before --
1. GNU -- extension. Everything after -- is not treated as options
1. Multiple options not requiring argument can be grouped together.
   -abc is the same as -a -b -c
1. Argument does not require space. -wfile is same as -w file
1. Zero dependencies
1. 41 unit tests + 7 integration tests + 1 doc test

Usage
-----

#### Create getopt instance

  let g = **getopt3::new**(_arguments_, _optstring_)

  getopt3::new constructor arguments:
  
  1. _arguments_ command line arguments. Anything what can be converted to
                   iterator over String.
  2. _optstring_ is a &str containing the legitimate option characters.
        If such a character is followed by a colon, the option requires an
        argument.

#### Check for results

  *getopt* structure returned by constructor has following members:
  1. _arguments_ : Vec \<String> command line arguments with options removed
  2. _options_map_ : HashMap \<char, bool> map of recognized options. option -> have_argument
  3. _options_ : HashMap \<char, String> options parsed. If option do not have argument, it is mapped to "" String,
     otherwise it is mapped to its argument as string.

#### Optional - Check if options are parsed correctly
  You can run strictness check by calling *validate(getopt)* function. Returns Result with getopt instance or
  error as String.

#### Example usage

```rust
  use std::env::args;
  let rc = getopt3::new(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
     };
  };
```
