From 0b02cbd797ab13ff0877031d83e2ecc85a7916b5 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 9 Aug 2026 19:23:49 +0800 Subject: feat(proj_mgr): add support for conditional directory removal Add `[[hide-dir]]` rule to remove entire directories when their condition evaluates to true, extending the existing file-level hide functionality to directory trees. --- mingling_cli/src/proj_mgr/cmd_proj_init.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mingling_cli/src/proj_mgr/cmd_proj_init.rs') diff --git a/mingling_cli/src/proj_mgr/cmd_proj_init.rs b/mingling_cli/src/proj_mgr/cmd_proj_init.rs index 6e3908b..1ef8d1e 100644 --- a/mingling_cli/src/proj_mgr/cmd_proj_init.rs +++ b/mingling_cli/src/proj_mgr/cmd_proj_init.rs @@ -187,6 +187,18 @@ pub fn handle_state_project_generate(_: StateProjectGenerate, cwd: &ResCurrentDi hidden.push(target); } + // hide-dir: delete the generated directory tree when the rule is true + for hide in &rules.hide_dirs { + if !eval_rule(&hide.rule, &answers) { + continue; + } + let target = cwd.join(hide.dir.trim_start_matches("./")); + remove_path(&target).map_err(|e| { + ErrorTemplateExpandFailed::new(format!("failed to hide {}: {e}", target.display())) + })?; + hidden.push(target); + } + // Clean up the cache fs::remove_dir_all(&tmpl_cache).map_err(|e| { ErrorTemplateExpandFailed::new(format!("failed to remove {}: {e}", tmpl_cache.display())) -- cgit