Module: Terraspace::Util::Sure

Included in:
CLI::Clean::Base, Terraform::Tfc::Runs::Base, Terraform::Tfc::Syncer, Terraspace::Util
Defined in:
lib/terraspace/util/sure.rb

Instance Method Summary collapse

Instance Method Details

#sure?(message = "Are you sure?", desc = nil) ⇒ Boolean

Returns:

  • (Boolean)


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

def sure?(message="Are you sure?", desc=nil)
  if @options[:yes]
    sure = 'y'
  else
    out = if desc
      "\n#{desc}\n#{message} (y/N) "
    else
      "#{message} (y/N) "
    end
    print out
    sure = $stdin.gets
  end

  unless sure =~ /^y/
    puts "Whew! Exiting."
    exit 0
  end
end