diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2024-12-22 17:45:13 +0800 |
commit | b834953fa61d816b9a955640ad12d244316ce904 (patch) | |
tree | 4197980a04943b42941d3fce7cb16d1f7ea400bd /tools/cru-py/cru/service/_base.py | |
parent | 7e85627eb0d0126baf1e698ffdeae0f3c5fc693d (diff) | |
download | crupest-b834953fa61d816b9a955640ad12d244316ce904.tar.gz crupest-b834953fa61d816b9a955640ad12d244316ce904.tar.bz2 crupest-b834953fa61d816b9a955640ad12d244316ce904.zip |
HALF WORK: 2024.12.22
code.
Diffstat (limited to 'tools/cru-py/cru/service/_base.py')
-rw-r--r-- | tools/cru-py/cru/service/_base.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/cru-py/cru/service/_base.py b/tools/cru-py/cru/service/_base.py new file mode 100644 index 0000000..707fb66 --- /dev/null +++ b/tools/cru-py/cru/service/_base.py @@ -0,0 +1,23 @@ +from argparse import ArgumentParser, Namespace +from typing import Protocol +from cru.app import ApplicationPath, CruApplication + + +class AppFunction(Protocol): + @property + def name(self) -> str: ... + + def add_arg_parser(self, arg_parser: ArgumentParser) -> None: ... + + def run_command(self, args: Namespace) -> None: ... + + +class AppBase(CruApplication): + def __init__(self, name: str, app_dir: str): + super().__init__(name) + self._app_dir = app_dir + self._template_dir = ApplicationPath(app_dir, "templates", True) + + @property + def app_dir(self) -> str: + return self._app_dir |