TeXitoi / structopt

Parse command line arguments by defining a struct.
Other
2.7k stars 149 forks source link

panic if use required_unless a bool option #495

Closed pansila closed 3 years ago

pansila commented 3 years ago
struct Opt {
    #[structopt(short, long)]
    debug: bool,

    #[structopt(name = "URL", required_unless("register"))]
    url: String,

    #[structopt(short, long, help = "Register as the default web browser")]
    register: bool,
}
$ cargo run -- --register
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\main.rs:24:10
pansila commented 3 years ago

Should use url: Option\<String> instead.