From 7dff1fa5516c0581e7c8a714a6a47e7331df83f2 Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <technomancy@gmail.com>
Date: Sat, 24 Apr 2010 08:08:56 -0700
Subject: [PATCH 1/2] Add support for running -main namespaces from clojure.main.

Signed-off-by: Stephen C. Gilardi <scgilardi@gmail.com>
---
 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 6f08c6f..6358d25 100644
--- a/src/clj/clojure/main.clj
+++ b/src/clj/clojure/main.clj
@@ -255,6 +255,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]
@@ -281,6 +289,8 @@
   (or
    ({"-r"     repl-opt
      "--repl" repl-opt
+     "-m"     main-opt
+     "--main" main-opt
      nil      null-opt
      "-h"     help-opt
      "--help" help-opt
@@ -319,6 +329,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
 
-- 
1.7.0.4


From c8875e3bb819f33239841cc09f1619ed7da487d6 Mon Sep 17 00:00:00 2001
From: Stephen C. Gilardi <scgilardi@gmail.com>
Date: Fri, 30 Apr 2010 02:20:56 -0400
Subject: [PATCH 2/2] 315: minor tweaks to documentation over phil's patch

---
 src/clj/clojure/main.clj |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj
index 6358d25..8c44857 100644
--- a/src/clj/clojure/main.clj
+++ b/src/clj/clojure/main.clj
@@ -245,6 +245,14 @@
   (doseq [[opt arg] inits]
     ((init-dispatch opt) arg)))
 
+(defn- main-opt
+  "Call the -main function from a namespace with string arguments from
+  the command line."
+  [[_ main-ns & args] inits]
+  (with-bindings
+    (initialize args inits)
+    (apply (ns-resolve (doto (symbol main-ns) require) '-main) args)))
+
 (defn- repl-opt
   "Start a repl with args and inits. Print greeting if no eval options were
   present"
@@ -255,14 +263,6 @@
   (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]
@@ -323,15 +323,15 @@ java -cp clojure.jar clojure.main -i init.clj script.clj args...")
   With no options or args, runs an interactive Read-Eval-Print Loop
 
   init options:
-    -i, --init path   Load a file or resource
-    -e, --eval string Evaluate expressions in string; print non-nil values
+    -i, --init path     Load a file or resource
+    -e, --eval string   Evaluate expressions in string; print non-nil values
 
   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
+    -m, --main ns-name  Call the -main function from a namespace with args
+    -r, --repl          Run a repl
+    path                Run a script from from a file or resource
+    -                   Run a script from standard input
+    -h, -?, --help      Print this help message and exit
 
   operation:
 
@@ -340,7 +340,7 @@ java -cp clojure.jar clojure.main -i init.clj script.clj args...")
     - Binds *command-line-args* to a seq of strings containing command line
       args that appear after any main option
     - Runs all init options in order
-    - Runs a repl or script if requested
+    - Calls a -main function or runs a repl or script if requested
 
   The init options may be repeated and mixed freely, but must appear before
   any main option. The appearance of any eval option before running a repl
-- 
1.7.0.4

