aboutsummaryrefslogtreecommitdiff
path: root/tools/cru-py/cru/service/_app.py
blob: a656e3b4063b9c5ef1155a76d7f97791ea4a8d2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from ._base import AppBase, CommandDispatcher, AppInitializer, OWNER_NAME
from ._config import ConfigManager
from ._data import DataManager
from ._template import TemplateManager


class App(AppBase):
    def __init__(self):
        super().__init__(f"{OWNER_NAME}-service")
        self.add_feature(AppInitializer())
        self.add_feature(DataManager())
        self.add_feature(ConfigManager())
        self.add_feature(TemplateManager())
        self.add_feature(CommandDispatcher())

    def run_command(self):
        command_dispatcher = self.get_feature(CommandDispatcher)
        command_dispatcher.run_command()


def create_app() -> App:
    app = App()
    app.setup()
    return app