Scripting with Clojure

耗尽温柔 提交于 2019-12-09 11:44:43

问题


I was trying to do some simple scripting work with Clojure. For example, I would load a json which contains a map from a file, remove a given key, and save it back to the file. With leiningen, seems I would have to create an app, add data.json or whatever into the dependencies, then I could start a lein repl to do the real work. Think about doing the same thing with Python. It should be done with 3 lines of code in Python. Is there an easy way to do it with leiningen?


回答1:


You can try out the lein-oneoff plugin which was made for situations like these (I'm the author). It lets you declare dependencies and write code in a single file, avoiding the need to generate a proper leiningen project.




回答2:


You can use lein-exec.

To add a bit more info, I wrote up some notes on standalone scripts with Clojure.



来源:https://stackoverflow.com/questions/16781023/scripting-with-clojure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!