locode_host/rg.rs
1//! Ripgrep binary resolution (ADR-0011).
2
3use std::path::PathBuf;
4
5/// The ripgrep program to invoke: the `LOCODE_RG_PATH` override, else bare `rg` on PATH
6/// (invoked by name — PATH-hijack hygiene, per Claude Code).
7///
8/// Bundled self-extraction is a packaging concern layered in later (the `bundle-rg`
9/// feature, Task 14); if `rg` cannot be started, the caller surfaces a soft error rather
10/// than falling back to a divergent hand-rolled search.
11#[must_use]
12pub fn rg_program() -> PathBuf {
13 std::env::var_os("LOCODE_RG_PATH").map_or_else(|| PathBuf::from("rg"), PathBuf::from)
14}