Class: FlareUp::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/flare_up/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bailout(exit_code) ⇒ Object



119
120
121
# File 'lib/flare_up/cli.rb', line 119

def self.bailout(exit_code)
  exit(exit_code)
end

.command_formatter(sym) ⇒ Object

transforms the symbol method names to the corresponding class under the FlareUp::Command namespace



107
108
109
110
111
# File 'lib/flare_up/cli.rb', line 107

def self.command_formatter(sym)
  name = sym.to_s.split('_').map(&:capitalize).join
  # Ruby 1.9.3 cannot handle const_get for nested Classes (Ruby 2.0 can).
  "FlareUp::Command::#{name}".split("::").reduce(Object) { |a, e| a.const_get e }
end

.env_validator(options, option_name, env_variable_name, default_value = nil) ⇒ Object

Raises:

  • (ArgumentError)


113
114
115
116
117
# File 'lib/flare_up/cli.rb', line 113

def self.env_validator(options, option_name, env_variable_name, default_value=nil)
  options[option_name] ||= (ENVWrap.get(env_variable_name) || default_value)
  return if options[option_name]
  raise ArgumentError, "One of either the --#{option_name} option or the ENV['#{env_variable_name}'] must be set"
end

Instance Method Details

#copy(data_source, endpoint, database_name, table_name) ⇒ Object



65
66
67
68
69
# File 'lib/flare_up/cli.rb', line 65

def copy(data_source, endpoint, database_name, table_name)
  command_setup(data_source, endpoint, database_name, table_name)
  command = CLI.command_formatter __method__
  Boot.boot command
end