diff --git a/Cargo.lock b/Cargo.lock index 63ca0f9..e477cd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1529,6 +1529,7 @@ dependencies = [ "unicode-segmentation", "unicode-width", "url", + "vergen", ] [[package]] @@ -3135,6 +3136,12 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + [[package]] name = "ryu" version = "1.0.13" @@ -3974,6 +3981,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vergen" +version = "8.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b3c89c2c7e50f33e4d35527e5bf9c11d6d132226dbbd1753f0fbe9f19ef88c6" +dependencies = [ + "anyhow", + "rustversion", + "time 0.3.20", +] + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 68059c0..c03f765 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,12 @@ exclude = [".github", "CONTRIBUTING.md"] keywords = ["matrix", "chat", "tui", "vim"] categories = ["command-line-utilities"] rust-version = "1.66" +build = "build.rs" + +[build-dependencies.vergen] +version = "8" +default-features = false +features = ["build", "git", "gitcl",] [dependencies] arboard = "3.2.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b846162 --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +use std::error::Error; +use vergen::EmitBuilder; + +fn main() -> Result<(), Box> { + EmitBuilder::builder().git_sha(true).emit()?; + Ok(()) +} diff --git a/src/config.rs b/src/config.rs index d0d4b72..35058c2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -89,8 +89,13 @@ fn validate_profile_names(names: &HashMap) { } } +const VERSION: &str = match option_env!("VERGEN_GIT_SHA") { + None => env!("CARGO_PKG_VERSION"), + Some(_) => concat!(env!("CARGO_PKG_VERSION"), " (", env!("VERGEN_GIT_SHA"), ")"), +}; + #[derive(Parser)] -#[clap(version, about, long_about = None)] +#[clap(version = VERSION, about, long_about = None)] #[clap(propagate_version = true)] pub struct Iamb { #[clap(short = 'P', long, value_parser)] diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 0e520bb..872d464 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -538,7 +538,7 @@ impl Window for IambWindow { title.into(), ]; Spans(v) - } + }, } }