#!/bin/sh
exec ruby -w -x $0 ${1+"$@"} # -*- ruby -*-
#!ruby -w
# vim: set filetype=ruby : set sw=2

# An extended grep, with extended functionality including full regular
# expressions, contextual output, highlighting, detection and exclusion of
# nontext files, and complex matching criteria.

# $Id: glark,v 1.3 2006/04/10 15:22:52 jeugenepace Exp $

dir = File.dirname(File.dirname(File.expand_path(__FILE__)))

libpath = dir + "/share"
$:.unshift libpath

require 'glark/glark'

main

__END__
# prototype of forthcoming feature:

# multi-pass execution:
./glark --run=2 '/(\w+)\s*=\s*\d+/' *.c

# means extract twice:

first run:
    matches = Array.new
    GlarkOptions.matches = matches
    glark = Glark.new(ARGV, :write => false)
    glark.search($files)

second run:
    GlarkOptions.matches = nil
    expr = MultiOrExpression.new(matches)
    glark = Glark.new(ARGV, :expr => expr)
    glark.search($files)
