You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cargo run -- Foo
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target\debug\structopt-test.exe Foo`
Opt {
foo: None,
sub_opt: Foo
}
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target\debug\structopt-test.exe`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore\option.rs:335:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\structopt-test.exe` (exit code: 101)
In clap I used AppSettings::SubcommandRequiredElseHelp for the behaviour I wanted and I expected something similar when I wrote this.
The text was updated successfully, but these errors were encountered:
Jokler
changed the title
Flattened enum panics without subcommand
Flattened enum panics when no subcommand is supplied
Apr 28, 2018
TeXitoi
added
the
bug
This is a BUG. The fix may be released in a patch version even if considered breaking
label
Apr 28, 2018
This is a bug as it should never panic, but using flatten on an enum is quite meaningless. What do you want to do? isn't more subcommand that you want instead of flatten?
In your example, using subcommand instead of flatten will do what you want. Now, with the corrected version, flatten and subcommand will do the exact same thing.
In
clap
I usedAppSettings::SubcommandRequiredElseHelp
for the behaviour I wanted and I expected something similar when I wrote this.The text was updated successfully, but these errors were encountered: