From f19dd10caff1d6393bffb11189c7467e268a33df Mon Sep 17 00:00:00 2001 From: BanceDev Date: Fri, 27 Feb 2026 00:41:20 -0500 Subject: add the clean subcommand --- src/config.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index ecada2a..8e3437c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,15 +9,26 @@ pub enum ConfigCommand { Build, Install, Uninstall, + PostInstall, + PostUninstall, + Clean, } #[derive(Deserialize)] pub struct Config { pub update: Option, + pub dependencies: Option>, + pub hooks: Option, +} + +#[derive(Deserialize)] +pub struct Hooks { pub build: Option, pub install: Option, pub uninstall: Option, - pub dependencies: Option>, + pub post_install: Option, + pub post_uninstall: Option, + pub clean: Option, } impl Config { @@ -48,10 +59,15 @@ pub fn create_config(package: &str) -> Result<(), String> { let template = format!( r#"# {package} configuration update = "tagged" # no | live | tagged +dependencies = [] + +[hooks] build = "make" install = "make install" uninstall = "make uninstall" -dependencies = [] +post_install = "" +post_uninstall = "" +clean = "make clean" "# ); @@ -66,11 +82,15 @@ pub fn run_config_command( command: ConfigCommand, ) -> Result<(), String> { let config = Config::new(config_path).ok_or("config not found".to_string())?; + let hooks = config.hooks.ok_or("no hooks section".to_string())?; let cmd = match command { - ConfigCommand::Build => config.build, - ConfigCommand::Install => config.install, - ConfigCommand::Uninstall => config.uninstall, + ConfigCommand::Build => hooks.build, + ConfigCommand::Install => hooks.install, + ConfigCommand::Uninstall => hooks.uninstall, + ConfigCommand::PostInstall => hooks.post_install, + ConfigCommand::PostUninstall => hooks.post_uninstall, + ConfigCommand::Clean => hooks.clean, }; if let Some(c) = cmd { -- cgit v1.2.3-59-g8ed1b