Class: Kaboom::CLI

Inherits:
Thor
  • Object
show all
Includes:
Config, Utils, Thor::Actions
Defined in:
lib/kaboom.rb

Constant Summary

Constants included from Config

Kaboom::Config::DESTINATIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config

#database_config, #load_credentials, #load_env, #validate_repository!

Methods included from Utils

#confirm_proceed, #confirm_production_action, #say_and_exit, #validate_destination

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/kaboom.rb', line 26

def self.exit_on_failure?
  true
end

Instance Method Details

#console(destination = 'staging') ⇒ Object



35
36
37
38
39
40
41
# File 'lib/kaboom.rb', line 35

def console(destination = 'staging')
  validate_repository!
  validate_destination(destination)

  confirm_production_action('console') if destination == 'production'
  run_command("bundle exec rails c", destination)
end

#ssh(destination = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/kaboom.rb', line 46

def ssh(destination = nil)
  if options[:server] && options[:role] != 'web'
    say "Warning: server option is supplied, role option will be ignored", :yellow
  end

  destination ||= 'staging' # Use default if destination is nil
  validate_repository!
  validate_destination(destination)

  confirm_production_action('SSH') if destination == 'production'

  if options[:server]
    server_user, server_host = get_server_user_and_host(destination)
    say "Running SSH on #{server_host} as #{server_user} (#{destination})...", :green
    exec("ssh #{server_user}@#{server_host}")
  else
    run_command("bash", destination)
  end
end