Rudimentary parsing to get the command

def _rudimentary_get_command(self, args):
        """ Rudimentary parsing to get the command """
        nouns = []
        command_names = self.commands_loader.command_table.keys()
        for arg in args:
            if arg and arg[0] != '-':
                nouns.append(arg)
            else:
                break

        def _find_args(args):
            search = ' '.join(args).lower()
            return next((x for x in command_names if x.startswith(search)), False)

        # since the command name may be immediately followed by a positional arg, strip those off
        while nouns and not _find_args(nouns):
            del nouns[-1]

        # ensure the command string is case-insensitive
        for i in range(len(nouns)):
            args[i] = args[i].lower()

        return ' '.join(nouns)