Closed palant closed 4 months ago
Consider the following application:
use structopt::StructOpt; /// Inner description #[derive(Debug, StructOpt)] struct OptInner {} /// Outer description #[derive(Debug, StructOpt)] struct OptOuter { #[structopt(flatten)] inner: OptInner } fn main() { OptOuter::from_args(); }
Running cargo run -- -h produces the following help text:
cargo run -- -h
test 0.1.0 Inner description USAGE: test FLAGS: -h, --help Prints help information -V, --version Prints version information
Note that the application description belongs to OptInner, not OptOuter as expected. Running cargo expand shows the issue:
OptInner
OptOuter
cargo expand
let app = app.about("Outer description"); let app = <OptInner as ::structopt::StructOptInternal>::augment_clap(app);
So this first applies the attributes of the outer structure and calls augment_clap() of the inner structure then which will overwrite them.
augment_clap()
The equivalent clap code does that in reverse order, producing the correct result:
let __clap_app = <OptInner as clap::Args>::augment_args(__clap_app); __clap_app.about("Outer description").long_about(None)
For reference: https://github.com/clap-rs/clap/issues/2527
Duplicate of #333
Consider the following application:
Running
cargo run -- -h
produces the following help text:Note that the application description belongs to
OptInner
, notOptOuter
as expected. Runningcargo expand
shows the issue:So this first applies the attributes of the outer structure and calls
augment_clap()
of the inner structure then which will overwrite them.The equivalent clap code does that in reverse order, producing the correct result:
For reference: https://github.com/clap-rs/clap/issues/2527