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
Setting #[structopt(version = expr)] (where expr is any expression, but not a literal) the expression is ignored and env!(CARGO_PKG_VERSION) is used instead.
It looks like the problem is clap::App::version is being called twice, first time with expr, and second time with the value of CARGO_PKG_VERSION, and the second call wins. In the expanded macro output I'm seeing something like:
let app = ::structopt::clap::App::new("example").version(VERSION).version("0.1.0");
Here is a reduction of my code that's seeing the problem:
use structopt::StructOpt;constVERSION:&str = "custom version";#[derive(StructOpt)]#[structopt(version = VERSION)]pubstructOpts{}fnmain(){let _ = Opts::from_args();}
As a workaround I can set #[structopt(no_version, version = VERSION)] and get the result I want, although looking at structopt_derive::attrs::Attrs::top_level_methods it doesn't look like this was intended to work.
The text was updated successfully, but these errors were encountered:
Setting
#[structopt(version = expr)]
(whereexpr
is any expression, but not a literal) the expression is ignored andenv!(CARGO_PKG_VERSION)
is used instead.It looks like the problem is
clap::App::version
is being called twice, first time withexpr
, and second time with the value ofCARGO_PKG_VERSION
, and the second call wins. In the expanded macro output I'm seeing something like:Here is a reduction of my code that's seeing the problem:
As a workaround I can set
#[structopt(no_version, version = VERSION)]
and get the result I want, although looking at structopt_derive::attrs::Attrs::top_level_methods it doesn't look like this was intended to work.The text was updated successfully, but these errors were encountered: