Closed paholg closed 2 years ago
Given the following code:
use structopt::StructOpt; #[derive(StructOpt, Debug)] struct Opt { #[structopt(long, short)] foo: bool, #[structopt(long, short, required_unless = "foo")] bar: String, } fn main() { let opt = Opt::from_args(); println!("Opt: {:?}", opt); }
Running cargo run -- --foo results in
cargo run -- --foo
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:9:10
Ideally, this would be a compiler error instead.
Structopt can't detect this sorry. It doesn't know what required_unless means.
Given the following code:
Running
cargo run -- --foo
results inIdeally, this would be a compiler error instead.