Method: CommandLine::Application.run

Defined in:
lib/commandline/application.rb

.run(argv = ARGV) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/commandline/application.rb', line 238

def self.run(argv=ARGV)
  # Usurp an existing initialize so ours can be called first.
  # We rename it __child_initialize and call it from initialize.
  if self.private_instance_methods(false).include?("initialize")
    $VERBOSE, verbose = nil, $VERBOSE
    self.class_eval {
      alias :__child_initialize :initialize
      remove_method :initialize
    }
    $VERBOSE = verbose
  end
  obj = self.new
  obj.__parse_command_line(argv)
  obj.main

  #alias :user_init :initialize
  #@@child_class.new.main if ($0 == @@appname)
  obj
  rescue => err
    puts "ERROR: #{err}"
    exit(-1)
end