| Crates.io | shadow-formatted-version |
| lib.rs | shadow-formatted-version |
| version | 1.1.1 |
| created_at | 2024-12-08 07:58:05.504997+00 |
| updated_at | 2025-08-23 03:16:14.048252+00 |
| description | Version information in a preformatted block |
| homepage | |
| repository | https://codeberg.org/trem/shadow-formatted-version |
| max_upload_size | |
| id | 1476104 |
| size | 37,586 |
Convenience crate to provide detailed version information in a preformatted block:
Version: 0.1.0
Target: x86_64-unknown-linux-gnu
Commit: 8f29a49b54ca3e94070d244511d8e4a64a69f083
Commit-Date: 2023-12-31 23:59:59 +00:00
Build-Date: 2024-12-31 23:59:59 +00:00
Build-Clean: No uncommitted changes in build.
Rust-Version: rustc 1.76.0 (07dca489a 2024-02-04)
This version information can be logged at the start of a long-running service or
printed when passing --version to a CLI.
For example, when using clap, you can use it like so:
#[derive(clap::Parser)]
#[command(about, version, long_version=crate::FORMATTED_VERSION)]
struct Args {
// ...
}
This crate is based on shadow-rs, which we will setup as well.
shadow-rs and shadow-formatted-version to your dependencies:[dependencies]
shadow-rs = "1"
shadow-formatted-version = "1.1"
[build-dependencies]
shadow-rs = "1"
build.rs file:fn main() {
shadow_rs::ShadowBuilder::builder()
.build().unwrap();
}
If you don't yet have a build.rs file, place it next to your Cargo.toml file:
.
├── build.rs
├── Cargo.toml
└── src
└── ...
main.rs or lib.rs, underneath your module definitions:shadow_rs::shadow!(build);
shadow_formatted_version::from_shadow!(build);
Then you can retrieve the formatted version information with crate::FORMATTED_VERSION.
You can also retrieve additional constants from crate::build, as generated by shadow-rs.