<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cli_wrapper(generator):
 """Given a wizard, implements an interactive command-line human-friendly interface for it. Parameters generator A generator such as one created by calling :py:func:`rig.wizard.wizard_generator`. Returns ------- dict or None Returns a dictionary containing the results of the wizard or None if the wizard failed. """

    first = True
    response = None
    while True:
        # Insert blank lines between prompts
        if not first:
            print()
        first = False

        try:
            message = generator.send(response)

            if isinstance(message, MultipleChoice):
                print(message.question)
                for num, choice in enumerate(message.options):
                    print("    {}: {}".format(num, choice))
                option = input("Select an option 0-{}{}: ".format(
                    len(message.options) - 1,
                    " (default: {})".format(message.default)
                    if message.default is not None else ""))

                if option == "" and message.default is not None:
                    option = message.default

                try:
                    response = int(option)
                except ValueError:
                    response = -1
                if not (0 <= response < len(message.options)):
                    print("ERROR: {} is not a valid option.".format(option))
                    return None
            elif isinstance(message, Text):
                print(message.question)
                response = input("> ")
            elif isinstance(message, Prompt):
                print(message.message)
                input("<Press enter to continue>")
                response = None
            elif isinstance(message, Info):  # pragma: no branch
                print(message.message)
                response = None

        except Failure as f:
            print("ERROR: {}".format(str(f)))
            return None
        except Success as s:
            return s.data