class CfDeployer::CLI

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/cf_deployer/cli.rb, line 5
def self.exit_on_failure?
  true
end

Public Instance Methods

config(environment) click to toggle source
# File lib/cf_deployer/cli.rb, line 36
def config environment
  prep_for_action :config, environment
  CfDeployer.config merged_options
end
deploy(environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 17
def deploy environment, component = nil
  prep_for_action :deploy, environment, component
  CfDeployer.deploy merged_options
end
destroy(environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 30
def destroy environment, component = nil
  prep_for_action :destroy, environment, component
  CfDeployer.destroy merged_options
end
detect_dry_run() click to toggle source
# File lib/cf_deployer/cli.rb, line 103
def detect_dry_run
  CfDeployer::Driver::DryRun.enable if options[:'dry-run']
end
diff(environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 42
def diff environment, component = nil
  prep_for_action :diff, environment, component
  CfDeployer.diff merged_options
end
error_exit(message) click to toggle source
# File lib/cf_deployer/cli.rb, line 119
def error_exit message
  puts message
  exit 1
end
json(environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 48
def json environment, component = nil
  prep_for_action :json, environment, component
  CfDeployer.json merged_options
end
kill_inactive(environment, component) click to toggle source
# File lib/cf_deployer/cli.rb, line 62
def kill_inactive environment, component
  prep_for_action :kill_inactive, environment, component
  CfDeployer.kill_inactive merged_options
end
merged_options() click to toggle source
# File lib/cf_deployer/cli.rb, line 88
def merged_options
  the_merge_options = {:environment => @environment, :component => @component}
  the_merge_options[:hook_name] = @hook_name if @hook_name
  symbolize_all_keys options.merge(the_merge_options)
end
prep_for_action(action, environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 75
def prep_for_action action, environment, component = nil
  no_component_required_actions = [:config, :status]
  if environment == 'help' || (no_component_required_actions.include? action && component == nil)
    self.class.command_help shell, action
    exit 0
  end
  @environment = environment
  @component = [component].compact
  validate_cli options
  set_log_level
  detect_dry_run
end
runhook(environment, component, hook_name) click to toggle source
# File lib/cf_deployer/cli.rb, line 23
def runhook environment, component, hook_name
  @hook_name = hook_name.to_sym
  prep_for_action :runhook, environment, component
  CfDeployer.runhook merged_options
end
set_log_level() click to toggle source
# File lib/cf_deployer/cli.rb, line 94
def set_log_level
  if options[:'log-level'] == 'aws-debug'
    CfDeployer::Log.level = 'debug'
    AWS.config :logger => Logger.new($stdout)
  else
    CfDeployer::Log.level = options[:'log-level']
  end
end
status(environment, component = nil) click to toggle source
# File lib/cf_deployer/cli.rb, line 56
def status environment, component = nil
  prep_for_action :status, environment, component
  CfDeployer.status merged_options
end
switch(environment, component) click to toggle source
# File lib/cf_deployer/cli.rb, line 68
def switch environment, component
  prep_for_action :switch, environment, component
  CfDeployer.switch merged_options
end
symbolize_all_keys(hash) click to toggle source
# File lib/cf_deployer/cli.rb, line 114
def symbolize_all_keys(hash)
  return hash unless hash.is_a?(Hash)
  hash.inject({}){|memo,(k,v)|  memo.delete(k); memo[k.to_sym] = symbolize_all_keys(v); memo}
end
validate_cli(cli_options) click to toggle source
# File lib/cf_deployer/cli.rb, line 107
def validate_cli cli_options
  unless File.file?(options[:'config-file'])
    error_exit "ERROR:  #{options[:'config-file']} is not a file."
  end
  error_exit "ERROR:  No environment specified!" unless @environment
end