Skip to content

Commit

Permalink
feat: Print the commit hash when passing --version to the gluon execu…
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
Marwes committed Aug 10, 2017
1 parent 02f5e66 commit 3a1e596
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions repl/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::process::Command;

fn main() {
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
// This is the closest thing to making sure we rebuild this every time a new commit is made
println!("cargo:rerun-if-changed=../.git/COMMIT_EDITMSG");
}
9 changes: 7 additions & 2 deletions repl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ fn fmt_stdio() -> Result<()> {
}

fn run() -> std::result::Result<(), Box<std::error::Error + Send + Sync>> {
const GLUON_VERSION: &'static str = env!("CARGO_PKG_VERSION");

let matches = clap_app!(gluon =>
(version: GLUON_VERSION)
(version: crate_version!())
(long_version:
concat!(
crate_version!(), "\n",
"commit: ", env!("GIT_HASH")
)
)
(about: "executes gluon programs")
(@arg REPL: -i --interactive "Starts the repl")
(@subcommand fmt =>
Expand Down

0 comments on commit 3a1e596

Please sign in to comment.