aboutsummaryrefslogtreecommitdiff
path: root/mingling_picker/README.md
blob: c83bff422c38905a89a08f7fcf961aeab8305077 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Mingling Picker

A command-line argument parser for [Mingling](https://github.com/mingling-rs/mingling), enabled by the `mingling/picker` feature.

```toml
[dependencies.mingling]
version = "0.3.0"
features = [
    "picker"
]
```

Of course, you can also use it as a standalone crate by replacing `mingling::picker` with `mingling_picker`:

```toml
[dependencies]
mingling_picker = "0.3.0"
```

## Chained Argument Parser

Provides a clean chained-call API for declaring arguments to parse:

```rust
let args: Vec<&str> = vec!["--name", "Bob", "--age", "24"];
let result = args
    .pick(&flag![name: String])
    .or(|| "Alice".to_string())
    .pick(&flag![age: i32])
    .or(|| 24)
    .post(|num| num.clamp(0, 120))
    .parse();
let (name, age): (String, i32) = a.unwrap();
```

## Parsing Function Library

Provides a pure function library `parselib` for analyzing the structure of command-line arguments.

```rust
use mingling::picker::parselib::*;
```