-
Notifications
You must be signed in to change notification settings - Fork 152
Closed
tbillington/kondo
#34Description
It seems that with 1.47.0 macro'ing structopt causes misbehavior in the functionality of structopt. I found out that a flag gets erroneously parsed as an option instead.
In this example:
use structopt::StructOpt;
macro_rules! command {
(
$(#[derive($($t:tt),+)])?
#[structopt(
name = $name:literal,
about = $about:literal,
$( $var:ident = $val:expr, )*
)]
struct $command:ident {
$(
$(#[$m:meta])*
$field:ident: $type:ty,
)*
}
) => (
$(#[derive($($t),+)])?
#[structopt(
name = $name,
about = $about,
$( $var = $val, )*
)]
struct $command {
$(
$(#[$m])*
$field: $type,
)*
}
);
}
command!{
#[derive(Debug, StructOpt)]
#[structopt(
name = "opts",
about = "Opts",
)]
struct Opts {
#[structopt(long = "x", help = "xxx")]
x: bool,
}
}
fn main() {
println!("{:?}", Opts::from_args());
}
when compiling with Rust 1.46.0
$ cargo +1.46.0 run -- --help
opts 0.1.0
Opts
USAGE:
x [FLAGS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
--x xxx
with Rust 1.47.0
$ cargo +1.47.0 run -- --help
opts 0.1.0
Opts
USAGE:
x --x <x>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--x <x> xxx
I believe that it might be because of rust-lang/rust#73084
Metadata
Metadata
Assignees
Labels
No labels