diff --git a/pasch/__init__.py b/pasch/__init__.py index e69de29..e6f54ec 100644 --- a/pasch/__init__.py +++ b/pasch/__init__.py @@ -0,0 +1,11 @@ +from . import modules +from .cmd import run_capture, run_check +from .orchestrator import Module, Orchestrator + +__all__: list[str] = [ + "Module", + "Orchestrator", + "modules", + "run_capture", + "run_check", +] diff --git a/pasch/modules/__init__.py b/pasch/modules/__init__.py new file mode 100644 index 0000000..6103a92 --- /dev/null +++ b/pasch/modules/__init__.py @@ -0,0 +1,5 @@ +from .echo import Echo + +__all__: list[str] = [ + "Echo", +] diff --git a/pasch/modules/echo.py b/pasch/modules/echo.py new file mode 100644 index 0000000..11a3202 --- /dev/null +++ b/pasch/modules/echo.py @@ -0,0 +1,14 @@ +from pasch.cmd import run_check +from pasch.orchestrator import Module, Orchestrator + + +class Echo(Module): + def __init__(self, orchestrator: Orchestrator) -> None: + super().__init__(orchestrator) + self.args: list[str] = [] + + def add(self, arg: str) -> None: + self.args.append(arg) + + def realize(self) -> None: + run_check("echo", *self.args) diff --git a/pasch/orchestrator.py b/pasch/orchestrator.py new file mode 100644 index 0000000..d205629 --- /dev/null +++ b/pasch/orchestrator.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod + + +class Module(ABC): + def __init__(self, orchestrator: Orchestrator) -> None: + self.orchestrator = orchestrator + self.orchestrator.register(self) + + @abstractmethod + def realize(self) -> None: ... + + +class Orchestrator: + def __init__(self) -> None: + self.frozen: bool = False + self.modules: list[Module] = [] + + def register(self, module: Module) -> None: + if self.frozen: + raise Exception("registering module wile orchestrator is frozen") + self.modules.append(module) + + def realize(self) -> None: + self.frozen = True + for module in reversed(self.modules): + module.realize() diff --git a/scripts/check b/scripts/check new file mode 100755 index 0000000..40ef2a2 --- /dev/null +++ b/scripts/check @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +uvx ruff check +uvx pyrefly check