I'm hoping to use the structopt crate to give the user a command line String argument that I can constrain to a simple list of strings for it's valid options. I'm hoping that structopt do it's usual great job of generating a nice help about them as well as detecting when a user attempts to provide a String value not in the acceptable set of options.
In short I want the command line String to behave logically like an enum does.
There's an enum_in_args.rs in the structopt examples that I hoped would do this but it sadly does not build.
I found this here: examples
That I found here: here: crates.io structopt page
fwiw/ here's the build error.
--> src/main.rs:3:5
|
3 | use clap::arg_enum;
| ^^^^ help: a similar path exists: `structopt::clap`
error: cannot determine resolution for the macro `arg_enum`
--> src/main.rs:6:1
|
6 | arg_enum! {
| ^^^^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error[E0433]: failed to resolve: use of undeclared type `Baz`
--> src/main.rs:18:36
|
18 | #[structopt(possible_values = &Baz::variants(), case_insensitive = true)]
| ^^^ use of undeclared type `Baz`
error[E0412]: cannot find type `Baz` in this scope
--> src/main.rs:19:8
|
19 | i: Baz,
| ^^^ not found in this scope
error[E0282]: type annotations needed
--> src/main.rs:19:8
|
17 | /// Important argument.
| ----------------------- this method call resolves to `T`
18 | #[structopt(possible_values = &Baz::variants(), case_insensitive = true)]
19 | i: Baz,
| ^^^ cannot infer type for type parameter `U` declared on the associated function `map`
Some errors have detailed explanations: E0282, E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `structopt` due to 5 previous errors
Here's my Cargo.toml dependency:
[dependencies]
structopt = "0.3.25"
Since structopt pulls in clap I don't think I should add that here. I tried and got even nastier build errors.
Any ideas on where I can actually find a working example would be great for this would be awesome!
Thanks so much!