2
votes

I have defined a -main function in a :gen-class :main true namespace in Clojure. I am trying to test it from the REPL.

My main function looks like this:

(defn -main [& args]
  ; ...
  )

and I am trying to call it with (ns/-main "-x" "foo"), (ns/-main "-x foo"), (ns/-main ["-x" "foo"]), (ns/-main (into-array String ["-x" "foo"]), etc., and all give me various errors.

How do I call this function from the REPL and pass in some command line arguments to test it?

Thanks.

1

1 Answers

6
votes

I tried to reproduce it:

(defn -main [& args]
  (apply str args)
  )

Then called like:

(-main "a" "b" "c")

And it evaluated to:

"abc"

As it should..

Be sure to check are you using the right namespace identifier, also see if anything weird is happening inside your -main function, like using a string as a number..

Also, it wouldn't hurt to see your error message on this..