diff --git a/deps.edn b/deps.edn index 2c3218d..bd313dc 100644 --- a/deps.edn +++ b/deps.edn @@ -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"}} diff --git a/src/giants_shoulders/repl.clj b/src/giants_shoulders/repl.clj new file mode 100644 index 0000000..bcf794e --- /dev/null +++ b/src/giants_shoulders/repl.clj @@ -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))