Skip to content

Commit

Permalink
Add a stripped back giants-shoulders repl ns
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Feb 9, 2024
1 parent ceff3f4 commit 4ab406d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
:aliases {:dev {:extra-paths ["test" "other-tests" "cljs-test-runner-out/gen"]}
:repl {:extra-deps {cider/cider-nrepl {:mvn/version "0.30.0"}
djblue/portal {:mvn/version "0.35.1"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}
com.taoensso/timbre {:mvn/version "6.0.4"}}}
:outdated {:deps {com.github.liquidz/antq {:mvn/version "2.2.999"}}
:main-opts ["-m" "antq.core"]}
:format {:deps {cljfmt/cljfmt {:mvn/version "0.9.2"}}
Expand Down
41 changes: 41 additions & 0 deletions src/giants_shoulders/repl.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(ns giants-shoulders.repl
(:require [nrepl.server :as nrepl]
[cider.nrepl :as cider]
[taoensso.timbre :as log]
[portal.api :as portal]
[rebel-readline.core :as rr]
[rebel-readline.clojure.line-reader :as rr-clr]
[rebel-readline.clojure.service.local :as rr-csl]
[rebel-readline.clojure.main :as rr-cm]
[clojure.main :as clj-main]))

(defn start!
"Start a development REPL, intended to be invoked from ./scripts/repl"
[{:keys [portal]}]

(log/info "Starting nREPL server")
(let [{:keys [port] :as _server} (nrepl/start-server :handler cider/cider-nrepl-handler)]
(log/info "nREPL server started on port" port)
(log/info "Writing port to .nrepl-port")
(spit ".nrepl-port" port))

(when portal
(log/info "Opening portal, use (tap> ...) to inspect values")
(portal/open)
(add-tap #'portal/submit))

(log/info "Starting interactive REPL")
(rr/with-line-reader
(rr-clr/create (rr-csl/create))
(clj-main/repl
:prompt (fn [])
:read (rr-cm/create-repl-read)))

(log/info "Shutting down")

(when portal
(log/info "Closing portal")
(portal/close))

(shutdown-agents)
(System/exit 0))

0 comments on commit 4ab406d

Please sign in to comment.