use std::process::exit;
use eyre::Result;
use crate::config::{Config, Settings};
use crate::shell::ShellType;
use crate::toolset::ToolsetBuilder;
#[derive(Debug, clap::Args)]
#[clap(hide = true)]
pub struct HookNotFound {
#[clap(long, short)]
shell: Option<ShellType>,
#[clap()]
bin: String,
}
impl HookNotFound {
pub fn run(self) -> Result<()> {
let config = Config::try_get()?;
let settings = Settings::try_get()?;
if settings.not_found_auto_install {
let mut ts = ToolsetBuilder::new().build(&config)?;
if ts.install_missing_bin(&self.bin)?.is_some() {
return Ok(());
}
}
exit(127);
}
}