Example #1
0
    def cmd_looper(self, input_handler, current_cmd, output):
        current_cmd.cmdloop(intro=output)

        user_command = current_cmd.current_command
        is_ethans = current_cmd == input_handler.cmd_b
        # is_azezs = current_cmd == input_handler.cmd_b

        # CMD Switcher
        if user_command == "do_switch_cmd":
            if is_ethans:
                current_cmd = input_handler.cmd_a
            else:
                current_cmd = input_handler.cmd_b
            current_cmd.current_command = ""
            self.cmd_looper(input_handler, current_cmd, "CMD Switched")

        # JS file checker
        if user_command == "do_create_uml":
            current_cmd.current_command = ""
            output = "UML Diagram generated ./uml.png"
            output_intro = "Make sure you select at least one "
            output_error = "Javascript file. There was a type error: "
            type_error_output = output_intro + output_error
                               
            if is_ethans:
                try:
                    my_data = self.is_file_or_dir_b(current_cmd.user_args)
                    self.handle_javascript(my_data, "b")
                except TypeError as type_error:
                    output = type_error_output + str(type_error)

            else:
                try:
                    my_data = self.is_file_or_dir_a(current_cmd.user_args)
                    self.handle_javascript(my_data, "a")
                except TypeError as t:
                    output = type_error_output + str(t)

            self.cmd_looper(input_handler, current_cmd, output)

        if user_command == "do_deserialize":
            my_serializer = Serializer()  # WRAP in try / catch
            deserialize_args = current_cmd.user_args
            if is_ethans:
                my_serializer.deserializer_b(deserialize_args)
            else:
                my_serializer.deserializer_a(deserialize_args)

            self.cmd_looper(input_handler, current_cmd, "")

        # Quitter
        if user_command == "do_quit":
            return