From 2c43e55f779beb12ce67e838e6d80b5f383ab64b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 4 Mar 2021 19:06:37 +0100 Subject: [PATCH] Improved command handling --- src/cpl_cli/command.py | 21 --------------------- src/cpl_cli/command_model.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 src/cpl_cli/command.py create mode 100644 src/cpl_cli/command_model.py diff --git a/src/cpl_cli/command.py b/src/cpl_cli/command.py deleted file mode 100644 index 64de906d..00000000 --- a/src/cpl_cli/command.py +++ /dev/null @@ -1,21 +0,0 @@ -from cpl.dependency_injection.service_abc import ServiceABC - - -class Command: - - def __init__(self, name: str, aliases: list[str], command: ServiceABC): - self._name = name - self._aliases = aliases - self._command = command - - @property - def name(self): - return self._name - - @property - def aliases(self): - return self._aliases - - @property - def command(self): - return self._command diff --git a/src/cpl_cli/command_model.py b/src/cpl_cli/command_model.py new file mode 100644 index 00000000..5d6f57fb --- /dev/null +++ b/src/cpl_cli/command_model.py @@ -0,0 +1,23 @@ +from collections import Callable + +from cpl_cli.command_abc import CommandABC + + +class CommandModel: + + def __init__(self, name: str, aliases: list[str], command: Callable[CommandABC]): + self._name = name + self._aliases = aliases + self._command = command + + @property + def name(self) -> str: + return self._name + + @property + def aliases(self) -> list[str]: + return self._aliases + + @property + def command(self) -> Callable[CommandABC]: + return self._command