Why do enums need a FromStr impl, but subcommands don’t? #1866
Answered
by
pksunkara
loewenheim
asked this question in
Q&A
-
Say i have a configuration struct #[derive(Clap)]
struct Config {
#[clap(subcommand)]
cmd: SubCommand,
#[clap(long = "foobar", value_name = "FOOBAR")]
foobar: FooBar,
} I can then simply add #[derive(Clap)]
enum SubCommand {
#[clap(name ="shake")]
Shake,
#[clap(name = "stir")]
Stir,
} But if I try to do the same thing with the #[derive(Clap)]
enum FooBar {
#[clap(name = "foo")]
Foo,
#[clap(name = "bar")]
Bar,
} … the compiler complains about a missing |
Beta Was this translation helpful? Give feedback.
Answered by
pksunkara
Apr 25, 2020
Replies: 1 comment 6 replies
-
|
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
pksunkara
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FooBar
needs aFromStr
impl so that the arguments provided to the clap program will be auto parsed and filled to it. What are you trying to do here?