def execute(self, command_args): try: repo = Repository() repo.name = command_args[1] repo.host = command_args[2] repo.port = command_args[3] repo.username = command_args[4] repo.database_driver = command_args[5] repo.database_name = command_args[6] repo.scripts_path = command_args[7] validate_repository(repo) if has_errors(repo): return console_out(errors_parser(repo)) except IndexError: console_error( "In executing command: {} Not all arguments have been passed.".format( command_to_plain_string(command_args) ) ) try: Repository.create(repo) except IntegrityError: console_error("Repository {} already exists.".format(repo.name)) return console_info("Repository {} created successfully.".format(repo.name))
def resolve_command(args): if not args: console_error("Type 'help' to see available commands") return try: available_commands[args[0].lower()]().execute(args) except KeyError as ex: console_error("Unknown command: {} \nType 'help' to see available commands".format(str(ex)))
def execute(self, command_args): if len(command_args) > 2: console_error("In executing command: {} To many arguments.".format(command_to_plain_string(command_args))) else: return console_out(get_available_commands())