diff options
author | Phil Hagelberg <technomancy@gmail.com> | 2010-04-24 08:08:56 -0700 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-10-15 07:26:04 -0400 |
commit | 5b1f4baf64146adae0c921cfdc077f661ec2fef5 (patch) | |
tree | d9be4c8e47fd18eec86b0308777ad9d0142773e6 | |
parent | c1b9d423cbcf59ffbe22da7363989d65cf11ac09 (diff) |
Add support for running -main namespaces from clojure.main.
Signed-off-by: Stephen C. Gilardi <scgilardi@gmail.com>
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | src/clj/clojure/main.clj | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj index f16096ec..fa05120a 100644 --- a/src/clj/clojure/main.clj +++ b/src/clj/clojure/main.clj @@ -258,6 +258,14 @@ (prn) (System/exit 0)) +(defn- main-opt + "Run the -main function from a given namespace with arguments taken from + the command line." + [[_ main-ns & args] inits] + (with-bindings + (initialize args inits) + (apply (ns-resolve (doto (symbol main-ns) require) '-main) args))) + (defn- script-opt "Run a script from a file, resource, or standard in with args and inits" [[path & args] inits] @@ -284,6 +292,8 @@ (or ({"-r" repl-opt "--repl" repl-opt + "-m" main-opt + "--main" main-opt nil null-opt "-h" help-opt "--help" help-opt @@ -322,6 +332,7 @@ java -cp clojure.jar clojure.main -i init.clj script.clj args...") main options: -r, --repl Run a repl path Run a script from from a file or resource + -m, --main Run the -main function from a given namespace - Run a script from standard input -h, -?, --help Print this help message and exit |