使用Clojure编写脚本 [英] Scripting with Clojure

查看:102
本文介绍了使用Clojure编写脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Clojure做一些简单的脚本工作.例如,我将加载一个包含文件映射的json,删除给定键,然后将其保存回文件中.使用leiningen,似乎我必须创建一个应用程序,将data.json或其他内容添加到依赖项中,然后才能启动lein repl来完成实际工作.考虑使用Python做同样的事情.应该使用Python中的3行代码来完成.有什么简单的方法可以使用莱宁根吗?

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?

推荐答案

您可以试用 lein-oneoff 插件这是针对此类情况(我是作者)制作的.它使您可以声明依赖项并在单个文件中编写代码,而无需生成正确的leiningen项目.

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.

这篇关于使用Clojure编写脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆