Created
September 25, 2010 01:22
-
-
Save tuor713/596336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'uwh.common.jline) | |
(use '[clojure.contrib.io :only (file read-lines)]) | |
(def processor (atom identity)) | |
(defn nil-safe [f] #(if (nil? %) % (f %))) | |
(defn add! [f] (swap! processor #(comp (nil-safe f) %))) | |
(run | |
(commands | |
(transform [f :file] | |
(doall (map (comp (nil-safe println) @processor) | |
(read-lines (file f))))) | |
(reset [] (reset! processor identity)) | |
(include [re :any] | |
(add! #(if (.matches % (str ".*" re ".*")) | |
% nil))) | |
(exclude [re :any] | |
(add! #(if (.matches % (str ".*" re ".*")) | |
nil %))) | |
(replace [re :any s :any] | |
(add! #(.replaceAll % re s))) | |
(exit [] (reset! *exit* true)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment