module Hoe::RakeHelpers

def ask_for_confirmation( description, abort_on_decline=true )

## any non-'y' answer will fail with an error message.
## with 'y', yield to the block. If +abort_on_decline+ is +true+,
## for confirmation. If the user answers with anything that begins
## Display a description of a potentially-dangerous task, and prompt
def ask_for_confirmation( description, abort_on_decline=true )
	prompt = 'Continue?'
	# If the description looks like a question, use it for the prompt. Otherwise,
	# print it out and
	if description.strip.rindex( '?' )
		prompt = description
	else
		log description
	end
	answer = prompt_with_default( prompt, 'n' ) do |input|
		input =~ /^[yn]/i
	end
	if answer =~ /^y/i
		return yield
	elsif abort_on_decline
		error "Aborted."
		fail
	end
	return false
end