Feature Request: choices
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
Similar to the [click](https://click.palletsprojects.com/en/8.1.x/options/#choice-options) arg parse library from Python, it would be nice if `argh` had a similar feature. I am new to rust, so I can't suggest a good interface, but perhaps something like:
```rust
#[derive(FromArgs, Debug)]
struct Args {
#[argh(choice, choices = vec!["foo", "bar", "baz"])]
thing_type: String
}
```
but an enum might be a better option:
```rust
#[derive(Debug)]
enum Choice {
Foo, Bar, Baz
}
#[derive(FromArgs, Debug)]
struct Args {
#[argh(choice, choices = Choice)]
thing_type: Choice
}
```
Perhaps this is possible already, but I couldn't figure out how to do so given the example and readme. Happy to close this if it is already possible.
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.