I'm trying to understand the very basics of structop
and I'm struggling. The code that I have now looks like this:
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "weather")]
struct Cli {
#[structopt(long, required=true, help="The name of the city for which you want to get the weather")]
city: Vec<String>,
#[structopt(long, required=true, help="The two-digit abbreviation for the state in which the city is located")]
state: Vec<String>
}
fn main() {
let cli = Cli::from_args();
println!("{:#?}", cli);
}
This produces:
S C:\Users\mthel\Rust\weather_cli> cargo run --city Chicago --state IL
error: Found argument '--city' which wasn't expected, or isn't valid in this context
USAGE:
cargo.exe run [OPTIONS] [--] [args]...
For more information try --help
However, this works:
PS C:\Users\mthel\Rust\weather_cli> cargo run -- --city Chicago --state IL
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target\debug\weather_cli.exe --city Chicago --state IL`
Cli {
city: [
"Chicago",
],
state: [
"IL",
],
}
I don't understand why the 'extra' --
is required at the beginning of the input.