Get an answer from stdin, the answers should be 'Y/n' etc.
    If you don't want the user can quit in the loop, then quit should be None.
547348
def get_answer(message, answers='Yn', default='Y', quit=''):
    
    if quit and quit not in answers:
        answers = answers + quit
        
    message = message + '(' + '/'.join(answers) + ')[' + default + ']:'
    ans = raw_input(message).strip().upper()
    if default and not ans:
        ans = default.upper()
    while ans not in answers.upper():
        ans = raw_input(message).strip().upper()
    if quit and ans == quit.upper():
        print "Command be cancelled!"
        sys.exit(0)
    return ans
1012461
def confirm_input(user_input):
    """"""
    if isinstance(user_input, list):
        user_input = ''.join(user_input)

    try:
        u_inp = user_input.lower().strip()
    except AttributeError:
        u_inp = user_input

    # Check for exit signal
    if u_inp in ('q', 'quit', 'exit'):
        sys.exit()
    if u_inp in ('y', 'yes'):
        return True
    return False
113859
def yes_no_query(question):
    

    print("{} (y/n)".format(question), end=" "),
    while True:
        try:
            return strtobool(input().lower())
        except ValueError:
            print("Please respond with 'y' or 'n'.")
588
def process_stdin(line):
    ''''''
    if line is None:
        sys.exit(0)

    line = line.strip()
    if not line:
        return

    args = shlex.split(line)
    cmd = args[0]
    if cmd == 'help':
        k = command_map.keys()
        k.sort()
        for cmd in k:
            (fn, help) = command_map[cmd]
            print("%-15s : %s" % (cmd, help))
        return
    if cmd == 'exit':
        mestate.exit = True
        return

    if not cmd in command_map:
        print("Unknown command '%s'" % line)
        return
    (fn, help) = command_map[cmd]
    try:
        fn(args[1:])
    except Exception as e:
        print("ERROR in command %s: %s" % (args[1:], str(e)))
323434
def ask_yes_no(*question: Token, default: bool = False) -> bool:
    """"""
    while True:
        tokens = [green, "::", reset] + list(question) + [reset]
        if default:
            tokens.append("(Y/n)")
        else:
            tokens.append("(y/N)")
        info(*tokens)
        answer = read_input()
        if answer.lower() in ["y", "yes"]:
            return True
        if answer.lower() in ["n", "no"]:
            return False
        if not answer:
            return default
        warning("Please answer by 'y' (yes) or 'n' (no) ")
610283
def confirm(text: str, default: bool = False) -> bool:
    """"""
    choices = "Y/n" if default else "y/N"
    prompt = f"{style(text, bold=True)} [{choices}]: "
    while 1:
        try:
            print(prompt, end="")
            value = input("").lower().strip()
        except (KeyboardInterrupt, EOFError):
            sys.exit(1)
        if value in ("y", "yes"):
            rv = True
        elif value in ("n", "no"):
            rv = False
        elif value == "":
            rv = default
        else:
            print_error("Error: invalid input")
            continue
        break
    return rv
648339
function(){
		_prompt.question("You entered '" + _destination + "'. Is this correct? (Y/N)\n", function(input){
			var response = input.trim().toLowerCase();
			evaluateConfirmation(response);
		});
	}
1048911
def _confirm_prompt(message, prompt="\nAre you sure? [y/yes (default: no)]: ",
                    affirmations=("Y", "Yes", "yes", "y")):
    
    answer = input(message + prompt)
    return answer in affirmations
36498
def prompt(prompt_string, default=None, secret=False, boolean=False, bool_type=None):
    
    if boolean or bool_type in BOOLEAN_DEFAULTS:
        if bool_type is None:
            bool_type = 'y_n'
        default_msg = BOOLEAN_DEFAULTS[bool_type][is_affirmative(default)]
    else:
        default_msg = " (default {val}): "
    prompt_string += (default_msg.format(val=default) if default else ": ")
    if secret:
        val = getpass(prompt_string)
    else:
        val = input(prompt_string)
    val = (val if val else default)
    if boolean:
        val = val.lower().startswith('y')
    return val
1113183
def _ask
      input = STDIN.gets.chomp
      input = @default if input.empty? && @default
      @fd.puts if @secret
      input
    end
631248
def loop_until_valid_response(prompt):
    
    responses = {"Y": True, "YES": True, "TRUE": True,
                 "N": False, "NO": False, "FALSE": False}
    response = ""
    while response.upper() not in responses:
        response = raw_input(prompt)

    return responses[response.upper()]
560530
def choice_prompt(prompt, choices=None, choice=None):
    '''
    
    '''
    if not choices:
        choices = ["y", "n", "Y", "N"]

    print(prompt)
    get_input = getattr(__builtins__, 'raw_input', input)
    pretty_choices = '/'.join(choices)
    message = 'Please enter your choice [%s] : ' %(pretty_choices)
    while choice not in choices:
        choice = get_input(message).strip()

        # If the option isn't valid, this is shown next
        message = "Please enter a valid option in [%s]" %(pretty_choices)    
    return choice
951757
def ask(message='Are you sure? [y/N]'):
    """"""
    agree = False
    answer = raw_input(message).lower()
    if answer.startswith('y'):
        agree = True
    return agree
179813
def _confirm_dialog(self, prompt):
        '''  '''
        response = raw_input(prompt).strip().lower()
        valid = {'y': True, 'ye': True, 'yes': True, 'n': False, 'no': False}
        while True:
            try:
                return valid[response]
            except:
                response = raw_input("Please respond 'y' or 'n': ").strip().lower()
785474
def _stdin_(p):
    """"""
    _v = sys.version[0]
    return input(p) if _v is '3' else raw_input(p)
1243414
def ask(self,
            patch_stdout: bool = False,
            kbi_msg: str = DEFAULT_KBI_MESSAGE) -> Any:
        """"""

        if self.should_skip_question:
            return self.default

        try:
            return self.unsafe_ask(patch_stdout)
        except KeyboardInterrupt:
            print("\n{}\n".format(kbi_msg))
            return None
455263
@Override
	public boolean promptYesNo(String message) {
		List<String> possibleValues = Arrays.asList(new String[] { "y", "n" });
		message += " (y/n): ";
		String line;

		do {
			line = new String(console.readLine(message));

			if (line != null && !possibleValues.contains(line)) {
				console.printf("Invalid selection");
			}
		} while (line == null || !possibleValues.contains(line));

		return "y".equalsIgnoreCase(line);
	}