from typing import Callable
from typing import Tuple
import logging


def user_input(prompt: str, obj_name: str, func: Callable) -> Tuple[object, str]:
    """Continually prompts a user for input until the specified object is found.

    :param prompt: Prompt to bother user with
    :param obj_name: Name of the type of the object that we seek
    :param func: The function that shalt be called to discover the object
    :return: The discovered object (vimtype) and it's human name"""
    while True:
        item_name = input(prompt)
        item = func(item_name)
        if item:
            logging.info("Found %s: %s", obj_name, item.name)
            return item, item_name
        else:
            print("Couldn't find a %s with name %s. Perhaps try another? "  # noqa: T001
                  % (obj_name, item_name))