Skip to content

Commit be92a99

Browse files
authored
fix commit and build date in version string (#93)
1 parent 03d789a commit be92a99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cli/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ fn main() -> color_eyre::Result<()> {
177177
if opts.version {
178178
let name = crate_name!();
179179
let version = crate_version!();
180-
let commit_hash = env::var("SUBWASM_CLI_GIT_COMMIT_HASH");
181-
let build_date = env::var("SUBWASM_CLI_BUILD_DATE");
180+
let commit_hash = option_env!("SUBWASM_CLI_GIT_COMMIT_HASH");
181+
let build_date = option_env!("SUBWASM_CLI_BUILD_DATE");
182182

183183
if !opts.json {
184-
let commit_hash_str = if let Ok(s) = commit_hash { format!("-{s}") } else { String::from("") };
185-
let build_date_str = if let Ok(s) = build_date { format!(" built {s}") } else { String::from("") };
184+
let commit_hash_str = commit_hash.map(|s| format!("-{s}")).unwrap_or_default();
185+
let build_date_str = build_date.map(|s| format!(" built {s}")).unwrap_or_default();
186+
186187
println!("{name} v{version}{commit_hash_str}{build_date_str}");
187188
} else {
188189
let version_data = json!({

0 commit comments

Comments
 (0)