Sha256: 2137aa392bf0501cf0d0a10d452ef5289dff1a228b45dcc445135f96fbb64bb2

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

#!/usr/bin/env ruby
require 'optparse'

options = {
  :delimiter => "\t",
  :interval => 1,
  :mode => :stat
}
OptionParser.new(ARGV) {|opt|
  opt.banner = "tail -f access.log | #{$0} <OPTIONS>"
  opt.on('-f [field]', Integer, 'value field') {|v| options[:field] = v - 1 }
  opt.on('-d [delimiter]', String) {|v| options[:delimiter] = v }
  opt.on('-i [interval]', Integer, 'interval for stat mode') {|v| options[:interval] = v }
  opt.on('-e [filter]', String) {|v| options[:filter] = v }
  opt.on('--stat', 'statistics mode (default)') { options[:mode] = :stat }
  opt.on('--print', 'print line mode') { options[:mode] = :print }
}.parse!

$: << File.expand_path('../../lib', __FILE__)
require "tailstrom/command/#{options[:mode]}"
cls = Module.const_get "Tailstrom::Command::#{options[:mode].capitalize}"
cmd = cls.new options
cmd.run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailstrom-0.0.3 bin/tailstrom
tailstrom-0.0.2 bin/tailstrom