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:
Steffen Eiden
2025-12-01 14:27:57 +01:00
parent 41ec030db1
commit 8a57017af3

View File

@@ -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)");)?
}