Class: PostRunner::Main

Inherits:
Object
  • Object
show all
Includes:
DirUtils
Defined in:
lib/postrunner/Main.rb

Instance Method Summary collapse

Methods included from DirUtils

#create_directory

Constructor Details

#initialize(args) ⇒ Main

Returns a new instance of Main.



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
64
# File 'lib/postrunner/Main.rb', line 33

def initialize(args)
  @filter = nil
  @name = nil
  @force = false
  @attribute = nil
  @value = nil
  @db_dir = File.join(ENV['HOME'], '.postrunner')

  return if (args = parse_options(args)).nil?

  unless $DEBUG
    Kernel.trap('INT') do
      begin
        Log.fatal('Aborting on user request!')
      rescue RuntimeError
        exit 1
      end
    end
  end

  begin
    main(args)
  rescue Exception => e
    if e.is_a?(SystemExit) || e.is_a?(Interrupt)
      $stderr.puts e.backtrace.join("\n") if $DEBUG
    else
      Log.fatal("#{e}\n#{e.backtrace.join("\n")}\n\n" +
                "#{'*' * 79}\nYou have triggered a bug in PostRunner " +
                "#{VERSION}!")
    end
  end
end