diff options
Diffstat (limited to 'tools/cru-py')
| -rw-r--r-- | tools/cru-py/cru/service/_template.py | 4 | ||||
| -rw-r--r-- | tools/cru-py/cru/template.py | 5 | 
2 files changed, 9 insertions, 0 deletions
| diff --git a/tools/cru-py/cru/service/_template.py b/tools/cru-py/cru/service/_template.py index ca2135f..b6affd1 100644 --- a/tools/cru-py/cru/service/_template.py +++ b/tools/cru-py/cru/service/_template.py @@ -1,4 +1,5 @@  from argparse import Namespace +import shutil  from cru import CruIterator  from cru.template import TemplateTree @@ -47,6 +48,8 @@ class TemplateManager(AppCommandFeatureProvider):      def _generate_files(self, dry_run: bool) -> None:          config_manager = self.app.get_feature(ConfigManager) +        if not dry_run: +            shutil.rmtree(self.generated_dir.full_path)          self.template_tree.generate_to(              self.generated_dir.full_path_str, config_manager.get_str_dict(), dry_run          ) @@ -78,3 +81,4 @@ class TemplateManager(AppCommandFeatureProvider):              self._generate_files(dry_run)              if dry_run:                  print("Dry run successfully.") +                print(f"Will delete dir {self.generated_dir.full_path_str}.") diff --git a/tools/cru-py/cru/template.py b/tools/cru-py/cru/template.py index 74a5c9a..9f0b560 100644 --- a/tools/cru-py/cru/template.py +++ b/tools/cru-py/cru/template.py @@ -142,6 +142,11 @@ class TemplateTree:      ) -> None:          for file, template in self.templates:              des = CruPath(destination) / file +            if self.template_file_suffix is not None and des.name.endswith( +                self.template_file_suffix +            ): +                des = des.parent / (des.name[: -len(self.template_file_suffix)]) +              text = template.generate(variables)              if not dry_run:                  des.parent.mkdir(parents=True, exist_ok=True) | 
