Ask to write some input with validation
960735
def write_input(message, default=nil, validator=nil, not_valid_message=nil)
      require 'highline/import'
      response =  ask(highline_quest(message)) do |q|
        q.default = default if default
        q.validate = /\.(.*)/ if validator
        q.responses[:not_valid] = highline_warn(not_valid_message) if not_valid_message
      end
      return response
    end
1231032
def boolean_input(self, question, default=None):
        '''
        
        '''
        result = input("%s: " % question)
        if not result and default is not None:
            return default
        while len(result) < 1 or result[0].lower() not in "yn":
            result = input("Please answer yes or no: ")
        return result[0].lower() == "y"
1084997
def input(self, more=False):
        """"""
        sys.stdout.flush()
        if more:
            msg = more_prompt
        else:
            msg = main_prompt
        if self.style is not None:
            internal_assert(prompt_toolkit is not None, "without prompt_toolkit cannot highlight style", self.style)
            try:
                return self.prompt(msg)
            except EOFError:
                raise  # issubclass(EOFError, Exception), so we have to do this
            except (Exception, AssertionError):
                logger.display_exc()
                logger.show_sig("Syntax highlighting failed; switching to --style none.")
                self.style = None
        return input(msg)
708739
function showIntro() {
    write("Welcome to the Recognizer's Sample console application!");
    write("To try the recognizers enter a phrase and let us show you the different outputs for each recognizer or just type 'exit' to leave the application.");
    write();
    write("Here are some examples you could try:");
    write();
    write("\" I want twenty meters of cable for tomorrow\"");
    write("\" I'll be available tomorrow from 11am to 2pm to receive up to 5kg of sugar\"");
    write("\" I'll be out between 4 and 22 this month\"");
    write("\" I was the fifth person to finish the 10 km race\"");
    write("\" The temperature this night will be of 40 deg celsius\"");
    write("\" The american stock exchange said a seat was sold for down $ 5,000 from the previous sale last friday\"");
    write("\" It happened when the baby was only ten months old\"");
    write("\" No, I don't think that we can make 100k USD today\"");
    write();
}
648339
function(){
		_prompt.question("You entered '" + _destination + "'. Is this correct? (Y/N)\n", function(input){
			var response = input.trim().toLowerCase();
			evaluateConfirmation(response);
		});
	}
448813
def float_input(self, question, message='Invalid entry', default=None, required=True):
        '''
        
        '''
        float_result = None
        requiredFlag = True

        while (float_result is None and requiredFlag):
            result = input('%s: ' % question)
            if not result and not required:
                float_result = None
                requiredFlag = False
            if not result and default:
                float_result = default

            if float_result is None and requiredFlag:
                try:
                    float_result = float(result)
                except ValueError:
                    self.stdout.write(self.style.ERROR(message))
                    float_result = None
        return float_result
1147465
function(input) {
		var needstesting = !this._matches.length;
		if (needstesting || this._matches.every(function(match) {
			return match.$instanceid !== input.$instanceid;
		})) {
			return this._maybeinput(input);
		}
		return false;
	}
712762
def _get_user_input(prompt, key_name, parent, input_func=raw_input):
    """"""
    val = input_func(prompt)
    ElementTree.SubElement(parent, "key").text = key_name
    if isinstance(val, bool):
        string_val = "true" if val else "false"
        ElementTree.SubElement(parent, string_val)
    else:
        ElementTree.SubElement(parent, "string").text = val
    return val
17220
def input(self, _in, out, **kw):
        """"""
        args = [self.binary or 'cleancss'] + self.rebase_opt
        if self.extra_args:
            args.extend(self.extra_args)
        self.subprocess(args, out, _in)
798533
def _ask(question, default=None, data_type='str', show_hint=False):
    """"""

    data = default

    if data_type == 'bool':
        data = None
        default_string = "Y" if default else "N"

        while data not in ('Y', 'J', 'N', '1', '0'):
            data = input("%s? [%s]: " % (question, default_string)).upper()

            if data == '':
                return default

        return data in ('Y', 'J', '1')

    elif data_type in ('str', 'unicode'):
        if show_hint:
            msg = "%s? [%s] (%s): " % (question, default, data_type)
        else:
            msg = question

        data = input(msg)

        if len(data) == 0:
            data = default
    elif data_type == 'int':
        if show_hint:
            msg = "%s? [%s] (%s): " % (question, default, data_type)
        else:
            msg = question

        data = input(msg)

        if len(data) == 0:
            data = int(default)
        else:
            data = int(data)

    return data
431259
def confirm(prompt=None, resp=False):
    
    if prompt is None:
        prompt = 'Confirm'

    if resp:
        prompt = '%s [%s]|%s: ' % (prompt, 'y', 'n')
    else:
        prompt = '%s [%s]|%s: ' % (prompt, 'n', 'y')

    while True:
        ans = raw_input(prompt)
        if not ans:
            return resp
        if ans not in ['y', 'Y', 'n', 'N']:
            print 'please enter y or n.'
            continue
        if ans == 'y' or ans == 'Y':
            return True
        if ans == 'n' or ans == 'N':
            return False
1029922
def validate(self, postdata, user = None):
        """"""
        clam.common.util.printdebug("Validating inputtemplate " + self.id + "...")
        errors, parameters, _  = processparameters(postdata, self.parameters, user)
        return errors, parameters
57085
def ask
      @fd.print full_message
      disable_echo if @secret

      input = _ask
      return input if valid(input)

      check_counter
      ask
    ensure
      enable_echo if @secret
    end
1005776
private boolean checkAnswer(String input) {
        StringTokenizer tok = new StringTokenizer(validAnswers, ANSWER_SEPARATOR);

        while (tok.hasMoreTokens()) {
            if (tok.nextElement().toString().trim().equalsIgnoreCase(input.trim())) {
                return true;
            }
        }

        log.info("User input is not valid - must be one of " + validAnswers);

        return false;
    }
192679
def validate(method):
    """"""

    @wraps(method)
    def mod_run(self, rinput):
        self.validate_input(rinput)
        #
        result = method(self, rinput)
        #
        self.validate_result(result)
        return result

    return mod_run
461931
def prompt_for_input(message, input_type=None):
    """"""
    while True:
        output = prompt.query(message)

        if input_type:
            try:
                output = input_type(output)
            except ValueError:
                error_message('Invalid input type')
                continue

        break

    return output
1112621
def input(self, prompt, type='', defaultLast=False, **kwargs):
        ''
        if type:
            histlist = list(self.lastInputs[type].keys())
            ret = self._inputLine(prompt, history=histlist, **kwargs)
            if ret:
                self.lastInputs[type][ret] = ret
            elif defaultLast:
                histlist or fail("no previous input")
                ret = histlist[-1]
        else:
            ret = self._inputLine(prompt, **kwargs)

        return ret