Class: PortalModule::Runner

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

Instance Method Summary collapse

Constructor Details

#initialize(argv, client = PortalModule::Client.new, exit_code = true) ⇒ Runner

Returns a new instance of Runner.



221
222
223
224
225
# File 'lib/portal_module.rb', line 221

def initialize(argv, client = PortalModule::Client.new, exit_code = true)
  @argv = argv
  PortalModule.client = client
  @exit_code = exit_code
end

Instance Method Details

#execute!Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/portal_module.rb', line 227

def execute!
  exit_code = begin

    # Run the Thor app
    PortalModule::CLI.start(@argv)

    # Thor::Base#start does not have a return value,
    # assume success if no exception is thrown.
    0
  rescue StandardError => e
    b = e.backtrace
    b.unshift("#{b.shift}: #{e.message} (#{e.class})")
    puts(b.map { |s| "\tfrom #{s}"}.join("\n"))
    1
  end

  # Return the exit code
  exit(exit_code) if @exit_code
end