Sha256: e367c2a98c8a559217ffb0de88819989692f48f774c2682544c8a16f685d8f0b
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
#!/usr/bin/env ruby $: << File.expand_path('../../lib', __FILE__) require 'optparse' def file_or_string(value) File.exist?(value) ? File.read(value) : value end options = { :delimiter => "\t", :interval => 1, :mode => :stat, :order => :desc } OptionParser.new(ARGV) {|opt| opt.banner = <<-END tail -f access.log | #{$0} [OPTIONS] #{$0} [OPTIONS] [file] END opt.on('-f num', Integer, 'value field') {|v| options[:field] = v } opt.on('-k num', Integer, 'key field') {|v| options[:key] = v } opt.on('-d delimiter', String, 'delimiter') {|v| options[:delimiter] = v } opt.on('-i interval', Integer, 'interval for stat mode') {|v| options[:interval] = v } opt.on('-e file_or_string', '--in-filter file_or_string', String, 'input filtering') do |v| options[:in_filter] = file_or_string v end opt.on('--map file_or_string', String, 'input mapping') do |v| options[:map] = file_or_string v end opt.on('--out-filter file_or_string', String, 'output filtering') do |v| options[:out_filter] = file_or_string v end opt.on('--sort file_or_string', String, 'output sorting') do |v| options[:sort] = file_or_string v end opt.on('--order desc|asc', String, 'sorting order (default=desc)') do |v| options[:order] = v.to_s.downcase == 'asc' ? :asc : :desc end opt.on('--stat', 'statistics mode (default)') { options[:mode] = :stat } opt.on('--print', 'print line mode') { options[:mode] = :print } opt.on('--version', 'show version') do require 'tailstrom/version' puts Tailstrom::VERSION exit 0 end }.order! if infile = ARGV.shift options[:static_infile] = open(infile, 'r') end require "tailstrom/command/#{options[:mode]}" cls = Tailstrom::Command.const_get options[:mode].to_s.capitalize cmd = cls.new options cmd.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tailstrom-0.0.6 | bin/tailstrom |