use crate::api::PluginContext;
use rustc_hash::FxHashMap;
use std::path::PathBuf;
use warpgate_api::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HookFunction {
PreInstall,
PostInstall,
PreRun,
}
impl HookFunction {
pub fn as_str(&self) -> &'static str {
match self {
Self::PreInstall => "pre_install",
Self::PostInstall => "post_install",
Self::PreRun => "pre_run",
}
}
}
impl AsRef<str> for HookFunction {
fn as_ref(&self) -> &str {
self.as_str()
}
}
api_struct!(
pub struct InstallHook {
pub context: PluginContext,
pub forced: bool,
pub passthrough_args: Vec<String>,
pub pinned: bool,
pub quiet: bool,
}
);
api_struct!(
pub struct RunHook {
pub context: PluginContext,
pub globals_dir: Option<VirtualPath>,
pub globals_prefix: Option<String>,
pub passthrough_args: Vec<String>,
}
);
api_struct!(
#[serde(default)]
pub struct RunHookResult {
#[serde(skip_serializing_if = "Option::is_none")]
pub args: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub env: Option<FxHashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub paths: Option<Vec<PathBuf>>,
}
);