You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't really a bug. The trick is that you need to annotate the variants, not the underlying struct: the attrs on it aren't used. This is a pretty common mistake people make with doc comments.
use structopt::StructOpt;#[derive(StructOpt)]enumApp{#[structopt(about = "testing", version = "v1337")]Baz(Baz),}#[derive(StructOpt)]structBaz{}fnmain(){App::from_args();}
probe.exe-baz v1337
testing
USAGE:
probe.exe baz
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
@CreepySkeleton true, but in the example I provided, the about field does work, despite the fact that it has been annotated on the struct and not the variant.
This is inconsistent behaviour, since the version field that has been annotated in the same place doesn't work.
structopt ignores explicitly set version numbers when used on a struct inside an enum.
To reproduce:
Now running
cargo run -- help baz
gives us:This is unexpected, since structopt ignores the
version
field, but uses theabout
field.Related issues:
version = expr
ignored, and incorrectly usesenv!(CARGO_PKG_VERSION)
#283The text was updated successfully, but these errors were encountered: