Override default version when using derive macros #1996
-
Hi, I'm using the derive macro's of clap 3 with a struct, and I want to be able to customize the version string that is used with the auto-generated If you're using the Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Ah right, thanks, I ended up with this: lazy_static! {
static ref VERSION: String = format!(
"{} {}",
String::from(option_env!("CARGO_PKG_VERSION").unwrap_or("dev")),
String::from(option_env!("SHA8").unwrap_or("workspace"))
);
}
#[derive(Clap, Debug)]
#[clap(version = VERSION.as_str())]
struct Args {
... |
Beta Was this translation helpful? Give feedback.
#[clap(version = "...")]
. "..." can be any expression of type&'static str