pnc 0.2.1

A fast, fully offline, terminal-only reverse Polish notation (RPN) calculator
use std::process::Command;

fn main() {
    let version = env!("CARGO_PKG_VERSION");
    let git_commit = Command::new("git")
        .args(["rev-parse", "--short", "HEAD"])
        .output()
        .ok()
        .and_then(|o| String::from_utf8(o.stdout).ok())
        .unwrap_or_else(|| "unknown".to_string())
        .trim()
        .to_string();
    let rustc = Command::new("rustc")
        .arg("--version")
        .output()
        .ok()
        .and_then(|o| String::from_utf8(o.stdout).ok())
        .unwrap_or_else(|| "unknown".to_string())
        .trim()
        .to_string();
    println!(
        "cargo:rustc-env=PNC_VERSION={} (git {}, {}, {}-{})",
        version,
        git_commit,
        rustc,
        std::env::consts::OS,
        std::env::consts::ARCH
    );
    println!("cargo:rerun-if-changed=../.git/HEAD");
}