//! Trait surface shared by every SCIP indexer install path.
//!
//! Two methods only — `name()` for error-prefix bytes, `install()` for the
//! end-to-end install (including the "already installed" early-return print).
//! Per-installer args live on the impl struct's fields, not as trait
//! method parameters.
//!
//! ## C2: augmented PATH threading
//!
//! `install` now receives a `&dyn BootstrapEnv` so every raw `Command::new`
//! spawn inside an installer can call `env.augmented_path()` and pass it
//! via `.env("PATH", ...)`. This ensures keg-only brew binaries discovered
//! during `RuntimeBootstrap::ensure` are still reachable in subsequent spawns
//! within the same session.

use std::path::Path;

use anyhow::Result;

use super::bootstrap::BootstrapEnv;

pub(super) struct InstallCtx<'a> {
    pub bin_dir: &'a Path,
    /// Auto-confirm package-manager installs of missing host runtimes.
    pub yes: bool,
}

pub(super) trait Installer {
    /// Lang token for dispatch / error messages (e.g. "rust", "ruby", "python").
    fn name(&self) -> &'static str;
    /// Performs the install, including the "already installed" early-return print + Ok.
    /// `env` carries the augmented PATH — every `Command::new` spawn MUST call
    /// `.env("PATH", env.augmented_path())` so keg-only binaries remain reachable.
    fn install(&self, ctx: &InstallCtx<'_>, env: &dyn BootstrapEnv) -> Result<()>;
}
