Skip to content

Commit c2bab05

Browse files
committed
feat: added version display
1 parent 9b09b42 commit c2bab05

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

compiler/compiler_main/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
let out = Command::new("git")
5+
.args(["rev-parse", "HEAD"])
6+
.output()
7+
.unwrap();
8+
9+
let git_hash = String::from_utf8(out.stdout).unwrap();
10+
11+
println!("cargo:rustc-env=GIT_HASH={}", git_hash.trim());
12+
}

compiler/compiler_main/src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
use clap::Parser;
22

3-
use crate::cli::{CLICommand, Cli};
3+
use crate::{
4+
cli::{CLICommand, Cli},
5+
version::{GIT_HASH, VERSION},
6+
};
47

58
pub mod cli;
9+
pub mod version;
610

711
fn main() {
812
let cli = Cli::parse();
13+
14+
match cli.command {
15+
CLICommand::Version => {
16+
println!("Quickfall v{} (commit {})", VERSION, GIT_HASH);
17+
}
18+
19+
_ => todo!(),
20+
}
921
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub const GIT_HASH: &str = env!("GIT_HASH");
2+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

0 commit comments

Comments
 (0)