File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -177,12 +177,13 @@ fn main() -> color_eyre::Result<()> {
177
177
if opts. version {
178
178
let name = crate_name ! ( ) ;
179
179
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" ) ;
182
182
183
183
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
+
186
187
println ! ( "{name} v{version}{commit_hash_str}{build_date_str}" ) ;
187
188
} else {
188
189
let version_data = json ! ( {
You can’t perform that action at this time.
0 commit comments