aboutsummaryrefslogtreecommitdiff
path: root/tools/cru-py/cru/service/_base.py
blob: 707fb6652c382ee667754b6f39ed2d7383412460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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