from prompt_toolkit import prompt
from validators import YesNoValidator
from prompt_toolkit.completion import WordCompleter


def ask_user(question, validator=None, completer=None, default=None):
    result = prompt(
        question,
        completer=completer,
        validator=validator,
        validate_while_typing=False
    )
    if result == '':
        return default
    return result


def ask_user_yes_no(question, default=None):
    result = prompt(
        question,
        completer=WordCompleter(['yes', 'no'], ignore_case=True),
        validator=YesNoValidator(),
        validate_while_typing=False
    )
    if result == 'yes':
        return True
    elif result == 'no':
        return False
    elif default == 'yes':
        return True
    return False


def wait_for_enter():
    prompt("Press enter to continue...")
