mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
uucore: add crate_version macro
This commit is contained in:
parent
e147063e26
commit
12ab9c2c21
2 changed files with 22 additions and 0 deletions
|
@ -1,2 +1,5 @@
|
|||
[target.x86_64-unknown-redox]
|
||||
linker = "x86_64-unknown-redox-gcc"
|
||||
|
||||
[env]
|
||||
PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils"
|
||||
|
|
|
@ -165,6 +165,25 @@ macro_rules! bin {
|
|||
};
|
||||
}
|
||||
|
||||
/// Generate the version string for clap.
|
||||
///
|
||||
/// The generated string has the format `(<project name>) <version>`, for
|
||||
/// example: "(uutils coreutils) 0.30.0". clap will then prefix it with the util name.
|
||||
///
|
||||
/// To use this macro, you have to add `PROJECT_NAME_FOR_VERSION_STRING = "<project name>"` to the
|
||||
/// `[env]` section in `.cargo/config.toml`.
|
||||
#[macro_export]
|
||||
macro_rules! crate_version {
|
||||
() => {
|
||||
concat!(
|
||||
"(",
|
||||
env!("PROJECT_NAME_FOR_VERSION_STRING"),
|
||||
") ",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/// Generate the usage string for clap.
|
||||
///
|
||||
/// This function does two things. It indents all but the first line to align
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue