diff options
Diffstat (limited to 'tools/cru-py/cru/service')
| -rw-r--r-- | tools/cru-py/cru/service/__main__.py | 11 | ||||
| -rw-r--r-- | tools/cru-py/cru/service/_base.py | 23 | ||||
| -rw-r--r-- | tools/cru-py/cru/service/_docker.py (renamed from tools/cru-py/cru/service/docker.py) | 0 | ||||
| -rw-r--r-- | tools/cru-py/cru/service/_manager.py | 2 | ||||
| -rw-r--r-- | tools/cru-py/cru/service/_template.py | 20 | 
5 files changed, 56 insertions, 0 deletions
| diff --git a/tools/cru-py/cru/service/__main__.py b/tools/cru-py/cru/service/__main__.py new file mode 100644 index 0000000..a7add4d --- /dev/null +++ b/tools/cru-py/cru/service/__main__.py @@ -0,0 +1,11 @@ +import argparse + + +arg_parser = argparse.ArgumentParser(description="Service management") +command_subparser = arg_parser.add_subparsers(dest="command") + +template_parser = command_subparser.add_parser("template", help="Template management") +template_subparser = template_parser.add_subparsers(dest="template_command") + +template_subparser.add_parser('list', description="List templates") +template_subparser.add_parser('generate') 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 diff --git a/tools/cru-py/cru/service/docker.py b/tools/cru-py/cru/service/_docker.py index 5958f4f..5958f4f 100644 --- a/tools/cru-py/cru/service/docker.py +++ b/tools/cru-py/cru/service/_docker.py diff --git a/tools/cru-py/cru/service/_manager.py b/tools/cru-py/cru/service/_manager.py index 45a9e47..c1af428 100644 --- a/tools/cru-py/cru/service/_manager.py +++ b/tools/cru-py/cru/service/_manager.py @@ -1,2 +1,4 @@  class CruServiceManager:      "TODO: Continue here tomorrow!" +    def __init__(self): +        
\ No newline at end of file diff --git a/tools/cru-py/cru/service/_template.py b/tools/cru-py/cru/service/_template.py new file mode 100644 index 0000000..0ca4b63 --- /dev/null +++ b/tools/cru-py/cru/service/_template.py @@ -0,0 +1,20 @@ +from argparse import ArgumentParser, Namespace + +from ._base import AppBase, AppFunction + + +class TemplateManager(AppFunction): +    def __init__(self, app: AppBase): +        self._app = app +        pass + +    @property +    def name(self): +        return "template-manager" + +    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") + +    def run_command(self, args: Namespace) -> None: ... | 
