Module: Kaboom::Utils
Instance Method Summary collapse
- #confirm_proceed(message, exit_on_no: true) ⇒ Object
- #confirm_production_action(command) ⇒ Object
- #say_and_exit(message, color) ⇒ Object
- #validate_destination(destination) ⇒ Object
Instance Method Details
#confirm_proceed(message, exit_on_no: true) ⇒ Object
18 19 20 |
# File 'lib/kaboom/helpers/utils.rb', line 18 def confirm_proceed(, exit_on_no: true) yes?( + " (y/n):", :yellow) || (exit_on_no ? (say("Action aborted", :red) && exit(1)) : false) end |
#confirm_production_action(command) ⇒ Object
14 15 16 |
# File 'lib/kaboom/helpers/utils.rb', line 14 def confirm_production_action(command) confirm_proceed("You are about to run a #{command} on a production environment. Are you sure you want to continue?") end |
#say_and_exit(message, color) ⇒ Object
3 4 5 6 |
# File 'lib/kaboom/helpers/utils.rb', line 3 def say_and_exit(, color) say , color exit(1) end |
#validate_destination(destination) ⇒ Object
8 9 10 11 12 |
# File 'lib/kaboom/helpers/utils.rb', line 8 def validate_destination(destination) unless Config::DESTINATIONS.include?(destination.to_sym) say_and_exit("Error: Unknown destination '#{destination}', valid destinations are: #{Config::DESTINATIONS.join(', ')}", :red) end end |