Replace IModule with AbstractModule
Delete CommandRunner Set up API to delegate the module execution to the module itself Update SampleModule
This commit is contained in:
parent
79449c8ad3
commit
af169b9598
@ -7,10 +7,6 @@ class AbstractModule(ABC):
|
||||
def __init__(self):
|
||||
super(AbstractModule, self).__init__()
|
||||
|
||||
@abstractmethod
|
||||
def get_command(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def run(self):
|
||||
pass
|
||||
|
@ -1,18 +0,0 @@
|
||||
class CommandRunner(object):
|
||||
"""docstring for CommandRunner."""
|
||||
|
||||
def __init__(self):
|
||||
super(CommandRunner).__init__()
|
||||
|
||||
def run(self, module):
|
||||
print("REAL RUNNER")
|
||||
print("Commands should be executed as subprocess.")
|
||||
|
||||
|
||||
class CommandRunnerDebug(object):
|
||||
def __init__(self):
|
||||
super(CommandRunnerDebug).__init__()
|
||||
|
||||
def run(self, module):
|
||||
print("DEBUG RUNNER")
|
||||
print(module.get_command())
|
3
main.py
3
main.py
@ -1,4 +1,3 @@
|
||||
from CommandRunner import CommandRunnerDebug as Runner
|
||||
from PyInquirer import prompt
|
||||
import importlib
|
||||
import os
|
||||
@ -46,4 +45,4 @@ modules = load_modules()
|
||||
selected_modules = open_module_selection(modules)
|
||||
|
||||
for answer in selected_modules['modules']:
|
||||
Runner().run(modules[answer])
|
||||
modules[answer].run()
|
||||
|
@ -8,10 +8,5 @@ class SampleModule(AbstractModule):
|
||||
super(SampleModule, self).__init__()
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
def get_command(self):
|
||||
return [
|
||||
"command 1",
|
||||
"command 2"
|
||||
]
|
||||
print("Command 1")
|
||||
print("Command 2")
|
||||
|
Loading…
Reference in New Issue
Block a user