Class: Maestro::CLI

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

Class Method Summary collapse

Class Method Details

.runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cli.rb', line 7

def run
  parse_options
  read_config
  
  ActiveResource::Base.logger = Logger.new($stdout) if Config[:verbose]
  abort("API Key is required") unless Config[:api_key]
  
  [ Story, Project ].each do |resource|
    resource.headers['X-APIKey'] = Config[:api_key]
  end
  
  puts Maestro::Dispatcher.invoke(ARGV.shift, ARGV)
rescue Maestro::Command::RuntimeError => e
  puts e.message
rescue Maestro::Command::ArgumentError => e
  puts e.message
rescue ActiveResource::UnauthorizedAccess => e
  puts "Access denied: Please check your API key"
end