Clojure: using *command-line-args* in the script rather than REPL
- by Teflon Mac
I've clojure running within Eclipse. I want to pass arguments to clojure when running it. In the below the arguments are available in the REPL but not in the script itself. What do I need to do such that in the below typing arg1 in the REPL will return the first argument?
Script:
(NS Test)
(def arg1 (nth *command-line-args* 0))
After clicking on the Eclipse "Run"...
Clojure 1.1.0
1:1 user=> #<Namespace test>
1:2 test=> arg1
nil
1:3 test=> *command-line-args*
("bird" "dog" "cat" "pig")
1:4 test=> (def arg2 (nth *command-line-args* 1))
#'test/arg2
1:5 test=> arg2
"dog"
1:6 test=>