Skip to content

Commit

Permalink
Update clj-bin files.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgrana committed Dec 27, 2009
1 parent 99adb09 commit 099fdf6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 107 deletions.
23 changes: 4 additions & 19 deletions clj-bin/clj
@@ -1,25 +1,10 @@
#!/bin/bash

USER_CLJ_DIR=/Users/mmcgrana/Clojure
SHARED_JARS_DIR=$USER_CLJ_DIR/jars

# Local src, test, and classes
CP=src/:test/:classes/

# Local jars
if [ -d jars ]; then
for file in jars/*.jar; do
CP=$CP:$file
done
fi

# Global jars.
for file in $SHARED_JARS_DIR/*.jar; do
CP=$CP:$file
done

if [ -z "$1" ]; then
echo "USAGE: cljp <script_file.clj>"
rlwrap java -Xmx2g -cp `cljcp` clojure.contrib.repl_ln
else
java -cp $CP clojure.main $@
fi
java -server -Xmx2g -cp `cljcp` clojure.main $USER_CLJ_DIR/run.clj $@
# java -server -Xmx2g -cp `cljcp` clojure.main $@
fi
24 changes: 24 additions & 0 deletions clj-bin/cljcp
@@ -0,0 +1,24 @@
#!/bin/bash

USER_CLJ_DIR=/Users/mmcgrana/Clojure

# Local src, test, and classes
CP=./:src/:src/clj/:src/main/clojure/
CP=$CP:test/:src/test/clojure/
CP=$CP:classes/

# Either local or glocal jars, but not both
if [ -d lib ]; then
for file in lib/*.jar; do
CP=$CP:$file
done
else
for file in $USER_CLJ_DIR/jars/*.jar; do
CP=$CP:$file
done
fi

# For user.clj
CP=$CP:$USER_CLJ_DIR

echo $CP
8 changes: 4 additions & 4 deletions clj-bin/cljd
Expand Up @@ -2,8 +2,8 @@

SHARED_JARS_DIR = "/Users/mmcgrana/Clojure/jars"

if (ARGV.size == 0) || (ARGV[1] == "help"):
puts "cljd <qi install uninstall extract list>"
if (ARGV.size == 0) || (ARGV[0] == "help"):
puts "Usage: cljd <qi install uninstall extract list>"

elsif ARGV[0] == "qi"
if ARGV.size != 1
Expand All @@ -25,7 +25,7 @@ elsif ARGV[0] == "install":

elsif ARGV[0] == "uninstall"
if ARGV.size != 2
puts "install <jar>"
puts "install <jar-file>"
else
jar = ARGV[1]
file = File.join(SHARED_JARS_DIR, jar)
Expand All @@ -39,7 +39,7 @@ elsif ARGV[0] == "uninstall"

elsif ARGV[0] == "extract":
if ARGV.size != 3
puts "cljd extract <jar> <dir>"
puts "cljd extract <jar-file> <dir>"
else
jar = ARGV[1]
dir = ARGV[2]
Expand Down
29 changes: 0 additions & 29 deletions clj-bin/clji

This file was deleted.

22 changes: 3 additions & 19 deletions clj-bin/cljp
@@ -1,26 +1,10 @@
#!/bin/bash

USER_CLJ_DIR=/Users/mmcgrana/Clojure
SHARED_JARS_DIR=$USER_CLJ_DIR/jars
YOURKIT_DYLB="/Applications/YourKit.app/bin/mac/libyjpagent.jnilib"

# Local src, test, and classes
CP=src/:test/:classes/

# Local jars
if [ -d jars ]; then
for file in jars/*.jar; do
CP=$CP:$file
done
fi

# Global jars.
for file in $SHARED_JARS_DIR/*.jar; do
CP=$CP:$file
done

if [ -z "$1" ]; then
echo "USAGE: cljp <script_file.clj>"
echo "Usage: cljp <script_file.clj>"
else
java -cp $CP -agentpath:$YOURKIT_DYLB clojure.main $@
fi
java -server -agentpath:$YOURKIT_DYLB -Xmx2g -cp `cljcp` clojure.main $USER_CLJ_DIR/run.clj $@
fi
11 changes: 11 additions & 0 deletions clj-bin/run.clj
@@ -0,0 +1,11 @@
(use 'clj-stacktrace.repl)
(import 'clojure.lang.Compiler)

(let [script-path (first *command-line-args*)
script-args (rest *command-line-args*)]
(binding [*command-line-args* script-args]
(try
(Compiler/loadFile script-path)
(catch Exception e
(pst-on *err* true e)
(System/exit 1)))))
38 changes: 2 additions & 36 deletions clj-bin/user.clj
@@ -1,42 +1,8 @@
;; Announce
(println "REPL Extensions")

;; Always-used libs
(use
'(clojure.contrib repl-utils repl-ln duck-streams)
'clj-backtrace.repl)

;; Macroexpansion utils
(defn- mapr
"recursively maps a function to a sequence and
subsequences within the map results."
[f & sequence]
(defn maprec [form]
(if (seq? form)
(map maprec (f form))
form))
(first (maprec sequence)))

(defn macroexpand-r
"Expands all macros in a form and its subforms."
[forms]
(mapr macroexpand forms))

(defn macroexpand-only
"Expands all macros in a form and its subforms that match a given symbol."
[macro forms]
(mapr
(fn [f] (if (= macro (first f)) (macroexpand f) f))
forms))
'(clojure.contrib repl-utils)
'(clj-stacktrace repl))

;; General REPL functions
(defn quit
"Quit the clojure process with a 0 status code."
[]
(System/exit 0))

(defn r
"Enter the line-numbering repl"
[]
(repl))

0 comments on commit 099fdf6

Please sign in to comment.