Class: FlareUp::CLI
- Inherits:
-
Thor
- Object
- Thor
- FlareUp::CLI
- Defined in:
- lib/flare_up/cli.rb
Class Method Summary collapse
-
.bailout(exit_code) ⇒ Object
TODO: Extract.
- .env_validator(options, option_name, env_variable_name) ⇒ Object
Instance Method Summary collapse
Class Method Details
.bailout(exit_code) ⇒ Object
TODO: Extract
51 52 53 |
# File 'lib/flare_up/cli.rb', line 51 def self.bailout(exit_code) exit(1) end |
.env_validator(options, option_name, env_variable_name) ⇒ Object
44 45 46 47 48 |
# File 'lib/flare_up/cli.rb', line 44 def self.env_validator(, option_name, env_variable_name) [option_name] ||= ENVWrap.get(env_variable_name) return if [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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/flare_up/cli.rb', line 21 def copy(data_source, endpoint, database_name, table_name) = { :data_source => data_source, :redshift_endpoint => endpoint, :database => database_name, :table => table_name } .each { |k, v| [k.to_sym] = v } begin CLI.env_validator(, :aws_access_key, 'AWS_ACCESS_KEY_ID') CLI.env_validator(, :aws_secret_key, 'AWS_SECRET_ACCESS_KEY') CLI.env_validator(, :redshift_username, 'REDSHIFT_USERNAME') CLI.env_validator(, :redshift_password, 'REDSHIFT_PASSWORD') rescue ArgumentError => e Emitter.error(e.) CLI.bailout(1) end Emitter.() Boot.boot() end |