repl-server

leiningen.repl

  • (repl-server project port)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source leiningen/repl.clj:8 top

(defn repl-server [project port]
  (let [init-form (and (:main project)
                       [:init `#(doto '~(:main project) require in-ns)])]
    `(do (ns ~'user
           (:use [~'clojure.main :only [~'repl]])
           (:import [java.net ~'InetAddress ~'ServerSocket ~'Socket
                     ~'SocketException]
                    [java.io ~'InputStreamReader ~'OutputStream
                     ~'OutputStreamWriter ~'PrintWriter]
                    [clojure.lang ~'LineNumberingPushbackReader]))
         (let [server# (ServerSocket. ~port)
               socket# (.accept server#)
               ins# (.getInputStream socket#)
               outs# (.getOutputStream socket#)]
           (binding [*in* (-> ins# InputStreamReader.
                              LineNumberingPushbackReader.)
                     *out* (OutputStreamWriter. outs#)
                     *err* (PrintWriter. outs# true)]
             (clojure.main/repl ~@init-form))
           (.close server#)))))
Vars in leiningen.repl/repl-server: defn let *err* *in* *out* -> apply binding concat list ns seq vector repl
Used in 0 other vars

Comments top

No comments for repl-server. Log in to add a comment.