`clap_long_version` should work as-is with clap-derive `#[clap(long_version = clap_long_version())]`
davidkna opened this issue · 4 comments
davidkna commented
Right now, clap_long_version()
(despite the name) is not supported as an argument with clap-derive via #[clap(long_version = clap_long_version())]
Sample:
use clap::Parser;
use crate::build::clap_long_version;
use shadow_rs::shadow;
shadow!(build);
#[derive(Parser, Debug)]
#[clap(long_version = clap_long_version())]
struct Config {
foo: String,
}
fn main() {
println!("{:?}", Config::parse());
}
Shadow-rs should work as-is in this scenario, without any wrapper function such as this:
fn long_version() -> &'static str {
let ver = Box::new(clap_long_version());
Box::leak(ver).as_str()
}
baoyachi commented
Hi @davidkna . Now shadow-rs 0.10.0 version can support this question.
Notice :Now, you can use Upper const CLAP_LONG_VERSION
, not clap_long_version()
E.g:
[dependencies]
shadow-rs = "0.10.1"
[build-dependencies]
shadow-rs = "0.10.1"
use clap::Parser;
use crate::build::CLAP_LONG_VERSION;
use shadow_rs::shadow;
shadow!(build);
#[derive(Parser, Debug)]
#[clap(long_version = CLAP_LONG_VERSION)]
struct Config {
foo: String,
}
fn main() {
println!("{:?}", Config::parse());
}
baoyachi commented
DONE .
davidkna commented
Thanks!