-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade Geni to v0.0.42 * Upgrade Clojure to v1.11.1 * Fix dependencies for REPL * Implement Datajure REPL
- Loading branch information
Showing
3 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(ns datajure.repl | ||
(:require | ||
[clojure.string] | ||
[clojure.java.io :as io] | ||
[nrepl.server] | ||
[reply.main])) | ||
|
||
(defn- client [opts] | ||
(let [port (:port opts) | ||
host (or (:host opts) "127.0.0.1") | ||
default-opts {:color true :history-file ".nrepl-history"} | ||
opts (assoc (merge default-opts opts) :attach (str host ":" port))] | ||
(reply.main/launch-nrepl opts))) | ||
|
||
(defn datajure-prompt | ||
"Custom Datajure REPL prompt." | ||
[ns-] | ||
(str "datajure-repl (" ns- ")> ")) | ||
|
||
(defn launch-repl | ||
"Starts an nREPL server and steps into a REPL-y." | ||
[opts] | ||
(let [port (:port opts) | ||
server (nrepl.server/start-server :port port)] | ||
(doto (io/file ".nrepl-port") .deleteOnExit (spit port)) | ||
(client (merge {:custom-prompt datajure-prompt} opts)) | ||
(nrepl.server/stop-server server))) | ||
|
||
(def welcome-note | ||
"A REPL welcome note." | ||
(str "Datajure " "1.0.1")) |