diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2024-12-27 16:16:29 +0800 |
commit | 7e9fdc36310d1bc63af4f4a0fc2f4963ae0154aa (patch) | |
tree | 32e9cdd3c2072ad16e9e1b68c8e4c252fa2749ed /tools/cru-py/cru/service/_template.py | |
parent | b834953fa61d816b9a955640ad12d244316ce904 (diff) | |
download | crupest-7e9fdc36310d1bc63af4f4a0fc2f4963ae0154aa.tar.gz crupest-7e9fdc36310d1bc63af4f4a0fc2f4963ae0154aa.tar.bz2 crupest-7e9fdc36310d1bc63af4f4a0fc2f4963ae0154aa.zip |
HALF WORK: 2024.12.27
Diffstat (limited to 'tools/cru-py/cru/service/_template.py')
-rw-r--r-- | tools/cru-py/cru/service/_template.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/cru-py/cru/service/_template.py b/tools/cru-py/cru/service/_template.py index 0ca4b63..5da00ba 100644 --- a/tools/cru-py/cru/service/_template.py +++ b/tools/cru-py/cru/service/_template.py @@ -1,20 +1,31 @@ from argparse import ArgumentParser, Namespace -from ._base import AppBase, AppFunction +from ._base import AppFeatureProvider +from cru.app import ApplicationPath +from cru.template import TemplateTree -class TemplateManager(AppFunction): - def __init__(self, app: AppBase): - self._app = app - pass + +class TemplateManager(AppFeatureProvider): + def __init__(self, prefix: str = "CRUPEST"): + super().__init__("template-manager") + self._templates_dir = self.add_app_path("templates", True) + self._generated_dir = self.add_app_path("generated", True) + self._template_tree = TemplateTree( + prefix, self._templates_dir.full_path_str, self._generated_dir.full_path_str + ) + + @property + def templates_dir(self) -> ApplicationPath: + return self._templates_dir @property - def name(self): - return "template-manager" + def generated_dir(self) -> ApplicationPath: + return self._generated_dir def add_arg_parser(self, arg_parser: ArgumentParser) -> None: subparsers = arg_parser.add_subparsers(dest="template_command") - list_parser = subparsers.add_parser("list", help="List templates") - generate_parser = subparsers.add_parser("generate", help="Generate template") + list_parser = subparsers.add_parser("list", help="List templates.") + generate_parser = subparsers.add_parser("generate", help="Generate template.") def run_command(self, args: Namespace) -> None: ... |