# File lib/simp/cli/config/items/item.rb, line 180 def query_ask # NOTE: This trailing space at the end of the String obliquely instructs # Highline to keep the prompt on the same line as the question. If the # String did not end with a space or tab, Highline would move the input # prompt to the next line (which, for our purposes, looks confusing) value = ask( "<%= color('#{query_prompt}', WHITE, BOLD) %>: ", highline_question_type ) do |q| q.default = default_value unless default_value.to_s.empty? # validate input via the validate() method q.validate = lambda{ |x| validate( x )} # do this before constructing reply to invalid response, to allow # any specializations to q parameters to be made (e.g., q.default) query_extras q # if the answer is not valid, construct a reply: q.responses[:not_valid] = "<%= color( %q{Invalid answer!}, RED ) %>\n" q.responses[:not_valid] += "<%= color( %q{#{ (not_valid_message || description) }}, RED) %>\n" q.responses[:not_valid] += "#{q.question} |#{q.default}|" q end value end