如何从另一个目录运行lein(没有cd到项目目录)?

时间:2015-12-04 00:22:51

标签: clojure leiningen

假设我的<HTML> <HEAD> </HEAD> <BODY> <input type="text" id="Search"> <button id="Submit">Submit</button> <div id="restaurants"></div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script> $("#Submit").click(function(event){ event.preventDefault(); var th = '<tr><th>' + "Business" +'</th><th>' + "Address"+ '</th><th>'+ "Rating" + '</th><th>' + "Date" + '</th></tr>'; $("#restaurants").empty().html(th); var Searching = $("#Search").val(); $.ajax({ type : "GET", url : "http://www.cs.kent.ac.uk/people/staff/lb514/hygiene/hygiene.php", dataType : "json", data : {op : "searchname", name : Searching}, success : function(data){ if(data.length == 0){ // what to do when nothing returns alert("Nothing found"); }else{ $.each(data,function(key,results){ if(results.length > 1){ $("#restaurants").append( "<tr><td>" + results.business +"</td>"+ "<td>" + results.address + "</td>" + "<td>" + results.rating + "</td>" + "<td>" + results.date + "</td></tr>") } }); } }}); }); </script> </BODY> 项目位于lein且当前位置为/some/location/project,如何在不更改项目位置/another/location/的情况下运行lein版本?

例如,在maven中

cd /some/location/project

1 个答案:

答案 0 :(得分:0)

据我所知,lein没有这样的选项。你必须在目录中。 (也许其他人会纠正我。)但是,你可以写一个shell脚本来做你想要的。例如,在提供getopts实用程序的unix中,您可以使用以下脚本,该脚本可能被称为&#34; leinthere&#34;:

#!/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 "$@"