Class: Troo::Launcher

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

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Troo::Launcher

Parameters:

  • (Array)
  • []
  • []
  • []
  • (Kernel)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/troo/launcher.rb', line 9

def initialize(argv, stdin = STDIN,
                     stdout = STDOUT,
                     stderr = STDERR,
                     kernel = Kernel)
  @argv      = argv
  @stdin     = stdin
  @stdout    = stdout
  @stderr    = stderr
  @kernel    = kernel
  @exit_code = 1
end

Instance Method Details

#execute!String, NilClass

Returns:

  • (String, NilClass)


22
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
# File 'lib/troo/launcher.rb', line 22

def execute!
  $stdin, $stdout, $stderr = @stdin, @stdout, @stderr
  pad { Troo::CLI::Main.start(@argv) }
  @exit_code = 0
rescue ConfigurationNotFound
  pad do
    puts "Configuration cannot be found, please run " \
         "`troo wizard` to get started."
  end
rescue ConfigurationAborted
  pad { puts 'Configuration wizard aborted.' }
rescue Redis::CannotConnectError
  pad { puts 'Cannot connect to Redis database.' }
rescue ExpiredAccessToken
  pad do
    puts "Your Trello access token has expired, please run " \
         "`troo wizard` for help, or manually renew."
  end
rescue EndpointNotFound
  pad do
    puts "An unrecoverable error has occurred due to programmer " \
         "error. Please report this issue at:\n\n"                \
         "https://github.com/gavinlaking/troo/issues\n\n"         \
         "Thank you.\n"
  end
ensure
  $stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
  @kernel.exit(@exit_code)
end