Module: Lono::Cfn::Util

Included in:
Base, Delete
Defined in:
lib/lono/cfn/util.rb

Instance Method Summary collapse

Instance Method Details

#are_you_sure?(stack_name, action) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lono/cfn/util.rb', line 2

def are_you_sure?(stack_name, action)
  if @options[:sure]
    sure = 'y'
  else
    message = case action
    when :update
      "Are you sure you want to want to update the #{stack_name.colorize(:green)} stack with the changes? (y/N)"
    when :delete
      "Are you sure you want to want to delete the #{stack_name.colorize(:green)} stack? (y/N)"
    end
    puts message
    sure = $stdin.gets
  end

  unless sure =~ /^y/
    puts "Whew! Exiting without running #{action}."
    exit 0
  end
end