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) <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-01-30 16:53:51 -05:00
parent 41d20f1374
commit 5508d8464a
3 changed files with 25 additions and 0 deletions

11
Cargo.lock generated
View File

@@ -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",

View File

@@ -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"] }

10
build.rs Normal file
View File

@@ -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");
}