Class: Glark::App

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

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/glark/app/app.rb', line 14

def initialize
  begin
    Logue::Log.set_widths(-15, -40, -40)
    
    opts = AppOptions.new
    opts.run ARGV
    
    # To get rid of the annoying stack trace on ctrl-C:
    trap("INT") { abort }
    
    if opts.info_options.explain
      puts opts.match_spec.expr.explain
    end

    files = ARGV.size > 0 ? ARGV : [ '-' ]
    runner = Runner.new opts, files
    
    exit runner.exit_status
  rescue => e
    # show the message, and the stack trace only if verbose:
    $stderr.puts "error: #{e}"
    if Logue::Log.verbose
      $stderr.puts e.backtrace
      raise
    else
      exit 2
    end
  end
end