From 5508d8464a940fe792e53614fb77cff4091b274d Mon Sep 17 00:00:00 2001 From: Taylor Eernisse Date: Fri, 30 Jan 2026 16:53:51 -0500 Subject: [PATCH] build: Add clap_complete, libc dependencies and git hash build script Add clap_complete for shell completion generation and libc (unix-only) for SIGPIPE handling. Create build.rs to embed the git commit hash at compile time via cargo:rustc-env=GIT_HASH, enabling `lore version` to display the short hash alongside the version number. Co-Authored-By: Claude (us.anthropic.claude-opus-4-5-20251101-v1:0) --- Cargo.lock | 11 +++++++++++ Cargo.toml | 4 ++++ build.rs | 10 ++++++++++ 3 files changed, 25 insertions(+) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 6c584e2..216d4cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,6 +211,15 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_complete" +version = "4.5.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5d" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "4.5.49" @@ -1085,6 +1094,7 @@ dependencies = [ "async-stream", "chrono", "clap", + "clap_complete", "comfy-table", "console", "dialoguer", @@ -1092,6 +1102,7 @@ dependencies = [ "flate2", "futures", "indicatif", + "libc", "open", "rand", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index ecc913c..f3460fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ serde_json = "1" # CLI clap = { version = "4", features = ["derive", "env"] } +clap_complete = "4" dialoguer = "0.12" console = "0.16" indicatif = "0.18" @@ -46,6 +47,9 @@ flate2 = "1" chrono = { version = "0.4", features = ["serde"] } uuid = { version = "1", features = ["v4"] } +[target.'cfg(unix)'.dependencies] +libc = "0.2" + # Logging tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..f906720 --- /dev/null +++ b/build.rs @@ -0,0 +1,10 @@ +fn main() { + let hash = std::process::Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .output() + .ok() + .and_then(|o| String::from_utf8(o.stdout).ok()) + .unwrap_or_default(); + println!("cargo:rustc-env=GIT_HASH={}", hash.trim()); + println!("cargo:rerun-if-changed=.git/HEAD"); +}