如何使用leningen将.clj文件作为脚本运行? [英] How to run .clj file as a script using leningen?

查看:23
本文介绍了如何使用leningen将.clj文件作为脚本运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是之后的第二个问题Leiningen 中的独立 Clojure 包?

例如,我有一个文件hello_world.clj,我可以使用

For example, I have a file hello_world.clj, and I can run it using

java -cp clojure.jar clojure.main hello_world.clj.

既然 lein 已经包含了 Clojure(因为我可以直接运行 lein repl),有没有办法像

Since lein already contains Clojure (because I can run lein repl directly), is there a way to do the same thing like

lein script hello_world.clj by lein?

推荐答案

使用 lein-exec插件,来自 readme.md 的示例(更新为lein"而不是lein2")

use lein-exec plugin, example from readme.md (updated with "lein" instead of "lein2")

cat foo.clj | lein exec
lein exec -e '(println "foo" (+ 20 30))'
lein exec -ep "(use 'foo.bar) (pprint (map baz (range 200)))"
lein exec -p script/run-server.clj -p 8088
lein exec ~/common/delete-logs.clj

这篇关于如何使用leningen将.clj文件作为脚本运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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