module Hoe::RakeHelpers

def prompt( prompt_string, failure_msg="Try again." ) # :yields: response

:yields: response
## An optional failure message can also be passed in.
## test is provided, the prompt will repeat until the test returns true.
## return the user's input with leading and trailing spaces removed. If a
## Output the specified prompt_string as a prompt (in green) and
def prompt( prompt_string, failure_msg="Try again." ) # :yields: response
	prompt_string.chomp!
	prompt_string << ":" unless /\W$/.match( prompt_string )
	response = nil
	begin
		prompt = make_prompt_string( prompt_string )
		response = readline( prompt ) || ''
		response.strip!
		if block_given? && ! yield( response )
			error_message( failure_msg + "\n\n" )
			response = nil
		end
	end while response.nil?
	return response
end