Ejemplo n.º 1
0
class ApplicationLogic(object):
    def __init__(self):
        self.factory = CommandFactory()

    def command_execute_func(self):
        while True:
            line = input('==> ')
            self.factory.get_command(line).execute()

    def run_app(self):
        print('Вас приветсвует вирутальный помощник\n')
        self.command_execute_func()
Ejemplo n.º 2
0
import argparse

from Commands.CommandFactory import AbstractCommand
from Commands.CommandFactory import CommandFactory

if __name__ == '__main__':
    factory = CommandFactory()

    parser = argparse.ArgumentParser(
        description='Console app with sub-commands.')

    subparsers = parser.add_subparsers(title='commands', dest='command')

    for command in factory.commands:
        command_parser = subparsers.add_parser(command.name, help=command.help)

        for argument in command.arguments:
            command_parser.add_argument(argument)

    options = vars(parser.parse_args())

    command: AbstractCommand = factory.get_command(options['command'])
    command.execute(options)
Ejemplo n.º 3
0
from Commands.AbstractCommand import AbstractCommand
from Commands.CommandFactory import CommandFactory

if __name__ == '__main__':
    factory = CommandFactory()

    while True:
        line = input('==> ')
        command: AbstractCommand = factory.get_command(line)
        command.execute()