Class: SparkApi::CLI::ConsoleCLI

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

Constant Summary collapse

OPTIONS_ENV =
{
  :endpoint => "API_ENDPOINT",
  :ssl_verify => "SSL_VERIFY",
  # OAUTH2 Options
  :access_uri  => "ACCESS_URI",
  :authorization_uri => "AUTHORIZATION_URI",
  :redirect_uri => "REDIRECT_URI",
  :code => "CODE",
  :username=> "USERNAME",
  :password=> "PASSWORD",
  :client_id=> "CLIENT_ID",
  :client_secret=> "CLIENT_SECRET",
  # API AUTH Options
  :api_key => "API_KEY", 
  :api_secret => "API_SECRET",
  :api_user => "API_USER",
  # OTHER
  :debug=> "DEBUG",
  :middleware => "SPARK_MIDDLEWARE",
  :dictionary_version => "DICTIONARY_VERSION",
  :console => "SPARK_API_CONSOLE"  # not a public option, meant to distinguish bin/spark_api and script/console
}

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/spark_api/cli.rb', line 39

def self.execute(stdout, arguments=[])
  options = setup_options(stdout,arguments)
  libs =  " -r irb/completion"
  # Perhaps use a console_lib to store any extra methods I may want available in the cosole
  libs << (options[:oauth2] ? setup_oauth2 : setup_api_auth)
  
  bundler = (options[:console] ? "bundle exec" : "")  
  cmd = "#{export_env(options)} #{bundler} #{irb} #{libs} --simple-prompt"
  puts "Loading spark_api gem..."
  exec "#{cmd}"
end

.irbObject



51
52
53
# File 'lib/spark_api/cli.rb', line 51

def self.irb()
  RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
end