开发者

Testing Clojure main from REPL

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.


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..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜