use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Prereq {
    pub name: String,
    #[serde(default)]
    pub check: Option<String>,
    #[serde(default)]
    pub install: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct InstallMethod {
    pub id: String,
    #[serde(default)]
    pub label: Option<String>,
    pub command: String,
    #[serde(default)]
    pub requires: Vec<String>,
    /// When true, this command expects a TTY (wizard, confirm prompts, etc.).
    /// The batch runner skips parallel execution for these and runs them
    /// serially with inherited stdio.
    #[serde(default)]
    pub interactive: bool,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Source {
    BuiltIn,
    Custom,
    CustomOverride,
}

impl Source {
    pub fn label(self) -> &'static str {
        match self {
            Source::BuiltIn => "built-in",
            Source::Custom => "custom",
            Source::CustomOverride => "custom ◂ overrides built-in",
        }
    }
}
