Mercurial > rlm
view src/rlm/clj.clj @ 5:fca75c0e8f40
added stories.clj
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 01 Mar 2012 05:47:37 -0700 |
parents | 78a630e650d2 |
children |
line wrap: on
line source
1 #!/home/r/roBin/env-cool java -cp /home/r/roBin/libs/*:/home/r/roBin/src:/home/r/roBin/rlm-lib/* -Xms1g -Xmx1g clojure.main3 (ns rlm.clj4 (:use [clojure.contrib5 [duck-streams :only [file-str] ]6 command-line str-utils shell-out7 [seq :only [indexed]]]8 [rlm shell-write]))10 (defn clj [& args]11 (with-command-line args12 "Simple Clojure shebang (#!) lines"13 [[classpath c "java classpath in which this script will run. rlm is always on the classpath."14 "/home/r/roBin/libs/*:/home/r/roBin/rlm-lib/*:/home/r/roBin/src"]15 [memory m "how much memory should this stupid jvm be provided? (megabytes)" 1000]16 [garbage g "level of congestion after which the jvm starts garbage collecting (megabytes)"17 "30% of whatever memory is"]18 [libraries l "link in libraries under -Djava.library.path" ""]19 [configure conf "use a file with configureations to defeat shebang line limit don't double define things:) " "/dev/null"]20 target-files]22 (if (not (= configure "/dev/null"))23 (apply clj (into (re-split #" " (chomp (slurp configure))) target-files))25 (let [26 adjusted-garbage27 (if (string? garbage)28 (int (* 0.3 (Integer. memory)))29 garbage)]31 ;assemble arguments to be passed to java32 (let [java-args33 (into34 ["-cp" classpath35 (str "-Xmn" adjusted-garbage "M")36 (str "-Xmx" memory "M")37 (str "-Xms" memory "M")38 (str "-Djava.library.path=\"" libraries "\"")39 "clojure.main"]40 target-files)]41 (let [command (str "java " (str-join " " java-args))]42 (println command)43 (sw command)44 ))))))50 (if *command-line-args*51 (let [options #{"-c" "-g" "-m" "-l" "-conf"}52 fuck (split-with (fn [[index element]] (or (odd? index) (options element)))53 (indexed *command-line-args*))54 fuck2 (conj (apply vector (map last (first fuck))) (str-join " " (map last (last fuck))))55 ]56 (apply clj fuck2)))