Method: Strobe::CLI.start

Defined in:
lib/strobe/cli.rb

.start(args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/strobe/cli.rb', line 23

def self.start(args)
  begin
    $__ARGV = args
    IdentityMap.wrap do
      super
    end
  rescue Strobe::UnauthenticatedError => e
    if Settings.global[:token]
      puts "[ERROR] Your token is invalid, please login to get a valid token"
      CLI::Main.start( [ "login" ] )
      retry
    else
      raise e
    end
  end
rescue NotifiableError => e
  if $__ARGV.include?('--backtrace')
    require 'pp'
    puts "=== ERROR DATA ==="
    pp e.data
    puts "\n"
    raise
  end
  STDERR.puts "[ERROR] #{e.message}"
  ExceptionNotifier.notify(e, :action => args.join(" "))
  abort
rescue StrobeError => e
  raise if $__ARGV.include?('--backtrace')
  STDERR.puts "[ERROR] #{e.message}"
  abort
rescue Interrupt
  abort  "\nQuitting..."
rescue SystemExit => e
  exit e.status
rescue Exception => e
  warn "Unfortunately, a fatal error has occurred. " +
    "Please report this error to Strobe Support at " +
    "http://support.strobeapp.com/home so that we can fix it. Thanks!\n\n" +
    "VERSION: #{Strobe.user_agent}"
  raise e
end