aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-06-02 14:33:25 +0000
committerscgilardi <scgilardi@gmail.com>2009-06-02 14:33:25 +0000
commitd7a1bbcc8111525f85f056410b10dd517092b639 (patch)
tree9861f7c63f95b10b13ac737ae915930fa6d570e7 /src
parentdf27c0a710440e2fef44f799dc5933f29ced44e1 (diff)
repl_utils: add run*, run to execute namespaces
Diffstat (limited to 'src')
-rw-r--r--src/clojure/contrib/repl_utils.clj17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/clojure/contrib/repl_utils.clj b/src/clojure/contrib/repl_utils.clj
index 76730aae..f0986a5f 100644
--- a/src/clojure/contrib/repl_utils.clj
+++ b/src/clojure/contrib/repl_utils.clj
@@ -149,5 +149,22 @@
(let [tref (java.lang.ref.WeakReference. t)]
(dosync (commute break-threads assoc (.getId t) tref)))))
+;; ----------------------------------------------------------------------
+;; scgilardi at gmail
+
+(defn run*
+ "Loads the specified namespace and invokes its \"main\" function with
+ optional args."
+ [ns-sym & args]
+ (require ns-sym :reload-all)
+ (apply (ns-resolve ns-sym 'main) args))
+
+(defmacro run
+ "Loads the specified namespace and invokes its \"main\" function with
+ optional args. ns-name is not evaluated."
+ [ns-name & args]
+ `(run* '~ns-name ~@args))
+
+;; ----------------------------------------------------------------------
(load "repl_utils/javadoc")