diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-09 19:23:49 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-09 19:23:49 +0800 |
| commit | 0b02cbd797ab13ff0877031d83e2ecc85a7916b5 (patch) | |
| tree | 6fbd0fc76e21bdaa2b779592412a48a6c9f4e9d6 /mingling_cli/src/proj_mgr/cmd_proj_init.rs | |
| parent | 3e9e70b32e8b1f77c81bd8652d9e53a3882d7297 (diff) | |
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.
Diffstat (limited to 'mingling_cli/src/proj_mgr/cmd_proj_init.rs')
| -rw-r--r-- | mingling_cli/src/proj_mgr/cmd_proj_init.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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())) |
