Class: RailsLogDeinterleaver::Cli

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

Instance Method Summary collapse

Constructor Details

#initializeCli

Returns a new instance of Cli.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rails_log_deinterleaver/cli.rb', line 5

def initialize
  opts = Trollop::options do
    opt :output, "Output file (if unspecified, output will go to stdout)", type: :string
    opt :backward, "Limit how many lines to go backward (default: no limit)", type: :integer
  end
  input = ARGV.last
  if opts[:output]
    opts[:output] = File.new(opts[:output], 'w')
  end
  raise 'Must specify input log file' unless input && File.exist?(input)

  Parser.new(input, opts).run
end