Clojure 如何从另一个目录运行lein(没有cd到项目目录)?
假设我的Clojure 如何从另一个目录运行lein(没有cd到项目目录)?,clojure,leiningen,Clojure,Leiningen,假设我的lein项目位于/some/location/project并且我的当前位置是/other/location/我如何运行lein构建而不更改到项目位置cd/some/location/project 例如,在maven中 mvn -f /path/to/pom.xml 据我所知,lein没有这样的选择。你必须在目录中。(也许其他人会纠正我。)但是,您可以编写一个shell脚本来实现您想要的功能。例如,在提供getopts实用程序的unix中,可以使用以下脚本,该脚本可能被称为“lein
lein
项目位于/some/location/project
并且我的当前位置是/other/location/
我如何运行lein
构建而不更改到项目位置cd/some/location/project
例如,在maven中
mvn -f /path/to/pom.xml
据我所知,
lein
没有这样的选择。你必须在目录中。(也许其他人会纠正我。)但是,您可以编写一个shell脚本来实现您想要的功能。例如,在提供getopts
实用程序的unix中,可以使用以下脚本,该脚本可能被称为“leinthere”:
你说得对
lein$task
在当前工作目录中查找project.clj
。
#!/bin/sh
if getopts f: option; then
# user supplied -f
if [ -d "$OPTARG" ]; then
# user also supplied name of a real dir, now in $OPTARG
cd "$OPTARG"
shift 2 # get rid of -f and the dir name
else
# user supplied -f, but not a real dir name
echo "usage: $0 [-f project-dir] [lein args]"
exit 1
fi
fi
# now just run lein in the normal way:
lein "$@"