Refactored Command to add owner

This commit is contained in:
2025-12-08 21:07:34 +01:00
parent 3aa36a91aa
commit 045f01b48a
19 changed files with 138 additions and 101 deletions

View File

@@ -25,10 +25,11 @@ class BaseCommand:
:type description: str
"""
def __init__(self, name, description, auto_register=True):
def __init__(self, name, description, owner=None, auto_register=True):
self.id = uuid.uuid4()
self.name = name
self.description = description
self.owner = owner
self._htmx_extra = {}
self._bindings = []
self._ft = None
@@ -133,8 +134,8 @@ class Command(BaseCommand):
:type kwargs: dict
"""
def __init__(self, name, description, callback, *args, **kwargs):
super().__init__(name, description)
def __init__(self, name, description, owner, callback, *args, **kwargs):
super().__init__(name, description, owner=owner)
self.callback = callback
self.callback_parameters = dict(inspect.signature(callback).parameters) if callback else {}
self.args = args
@@ -202,8 +203,8 @@ class Command(BaseCommand):
class LambdaCommand(Command):
def __init__(self, delegate, name="LambdaCommand", description="Lambda Command"):
super().__init__(name, description, delegate)
def __init__(self, owner, delegate, name="LambdaCommand", description="Lambda Command"):
super().__init__(name, description, owner, delegate)
self.htmx(target=None)
def execute(self, client_response: dict = None):