sh_cpl/src/cpl_cli/command_abc.py

26 lines
572 B
Python
Raw Normal View History

2021-03-29 13:29:26 +02:00
from abc import abstractmethod, ABC
2021-03-04 17:36:02 +01:00
from cpl_core.configuration.argument_executable_abc import ArgumentExecutableABC
2022-05-19 20:21:46 +02:00
from cpl_core.console import Console
2021-03-04 17:36:02 +01:00
2022-05-19 08:25:32 +02:00
class CommandABC(ArgumentExecutableABC):
2021-03-04 17:36:02 +01:00
@abstractmethod
def __init__(self):
2021-03-29 13:29:26 +02:00
ABC.__init__(self)
2021-03-04 17:36:02 +01:00
2021-04-11 16:36:59 +02:00
@property
@abstractmethod
def help_message(self) -> str: pass
2022-05-19 20:21:46 +02:00
@abstractmethod
def execute(self, args: list[str]): pass
def run(self, args: list[str]):
2022-05-19 20:21:46 +02:00
if 'help' in args:
Console.write_line(self.help_message)
return
self.execute(args)