I was excited to see #314 land, but I've not been able to get it working in my project. In order to sanity check myself I copied out a bare minimum based on the examples and tests in that PR but I'm still getting the same runtime panics.
use structopt::StructOpt;
#[derive(Debug, PartialEq, StructOpt)]
struct Opt {
#[structopt(subcommand)]
sub: Subcommands,
}
#[derive(Debug, PartialEq, StructOpt)]
enum Subcommands {
Add,
#[structopt(external_subcommand)]
Other(Vec<String>),
}
fn main() {
let opts = Opt::from_args();
println!("{:?}", opts);
}
λ cargo run -q -- add
Opt { sub: Add }
λ cargo run -q -- blah
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:14:15
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Here are the relevant backtrace lines:
λ env RUST_BACKTRACE=1 cargo run -q -- blah
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:14:15
stack backtrace:
...
14: core::option::Option<T>::unwrap
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/macros/mod.rs:10
15: <external::Subcommands as structopt::StructOptInternal>::from_subcommand
at src/main.rs:14
16: <external::Opt as structopt::StructOpt>::from_clap
at src/main.rs:5
17: structopt::StructOpt::from_args
at /home/scrogson/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-0.3.11/src/lib.rs:1073
18: external::main
at src/main.rs:18
...
It's unclear to me if I'm doing something wrong and there doesn't seem to be a working example in the examples directory.
Thanks in advance for your help!
I was excited to see #314 land, but I've not been able to get it working in my project. In order to sanity check myself I copied out a bare minimum based on the examples and tests in that PR but I'm still getting the same runtime panics.
Here are the relevant backtrace lines:
It's unclear to me if I'm doing something wrong and there doesn't seem to be a working example in the examples directory.
Thanks in advance for your help!