kiwi-scp/src/kiwi/runner.py

47 lines
962 B
Python
Raw Normal View History

2020-08-12 15:46:50 +00:00
# system
2020-08-11 12:03:00 +00:00
import logging
2020-08-12 15:46:50 +00:00
# local
2020-08-11 12:03:00 +00:00
from .config import LoadedConfig
from .parser import Parser
from .subcommands import *
###########
# CONSTANTS
SUBCOMMANDS = [
InitCommand,
ShowCommand,
LogsCommand
]
class Runner:
class __Runner:
__commands = []
def __init__(self):
for cmd in SUBCOMMANDS:
self.__commands.append(cmd())
2020-08-11 12:03:00 +00:00
def run(self):
config = LoadedConfig.get()
args = Parser().get_args()
for cmd in self.__commands:
2020-08-11 12:03:00 +00:00
if str(cmd) == args.command:
logging.debug(f"Running '{cmd}' with args: {args}")
cmd.run(config, args)
return True
return False
__instance = None
def __init__(self):
if Runner.__instance is None:
Runner.__instance = Runner.__Runner()
def __getattr__(self, item):
return getattr(self.__instance, item)