mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/utils: Add s390-tools version macro
This new macro allows (rust) tools reporting the s390-tools version string via clap functionalities, instead of implementing that on their own. That clap interface requires a string and not a void function that prints the version string. Define a macro that provides this string. Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
@@ -48,15 +48,21 @@ macro_rules! release_string {
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! tools_version_fmt {
|
||||
($year: expr) => {
|
||||
format!(
|
||||
"version {}\nCopyright IBM Corp. {}",
|
||||
$crate::release_string!(),
|
||||
$year
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! __print_version {
|
||||
($year: expr, $verbosity: expr $( ,$feat: expr)?) => {{
|
||||
println!(
|
||||
"{} version {}\nCopyright IBM Corp. {}",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
$crate::release_string!(),
|
||||
$year,
|
||||
);
|
||||
println!("{} {}", env!("CARGO_PKG_NAME"), $crate::tools_version_fmt!($year));
|
||||
if $verbosity > $crate::LevelFilter::Warn {
|
||||
$($feat.iter().for_each(|f| print!("{f} ")); println!("(compiled)");)?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user