Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
download-deps {:doc "bring down Clojure deps"
:task (clojure "-T:build download-deps")}

dev {:doc "Launch nREPL for development, --help for usage"
:task dev-repl/-main}

lint {:doc "[--rebuild] lint source code with clj-kondo"
:task lint/-main}

Expand Down
19 changes: 19 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
:1.11 {:override-deps {org.clojure/clojure {:mvn/version "1.11.4"}}}
:1.12 {:override-deps {org.clojure/clojure {:mvn/version "1.12.0"}}}

;;
;; REPL to support bb dev-jvm & dev-cljs tasks, see script/dev_repl.clj
;;
:nrepl
{:extra-deps {nrepl/nrepl {:mvn/version "1.3.1"}
cider/cider-nrepl {:mvn/version "0.55.7"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.11.0"}}
:jvm-opts ["-XX:-OmitStackTraceInFastThrow" "-Djdk.attach.allowAttachSelf"]
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[refactor-nrepl.middleware/wrap-refactor cider.nrepl/cider-middleware]"
"-i"]}

:flowstorm
{;; for disabling the official compiler
:classpath-overrides {org.clojure/clojure nil}
:extra-deps {com.github.flow-storm/clojure {:mvn/version "1.12.0-9"}
com.github.flow-storm/flow-storm-dbg {:mvn/version "4.4.2"}}
:jvm-opts ["-Dclojure.storm.instrumentEnable=true"]}

;; clojure -X support for local examples
:test-doc-blocks {:ns-default lread.test-doc-blocks}

Expand Down
69 changes: 69 additions & 0 deletions script/dev_repl.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(ns dev-repl)

(ns dev-repl
(:require [babashka.cli :as cli]
[babashka.process :as process]
[clojure.string :as str]
[helper.main :as main]
[lread.status-line :as status]))

(def cli-spec {:help {:desc "This usage help"}

:flowstorm {:alias :f
:coerce :boolean
:desc "Enable flowstorm"}

;; cider nrepl pass through opts
:host {:ref "<ADDR>"
:alias :h
:default "127.0.0.1"
:desc "Host address"}
:bind {:ref "<ADDR>"
:alias :b
:default "127.0.0.1"
:desc "Bind address"}
:port {:ref "<symbols>"
:coerce :int
:default 0
:alias :p
:desc "Port, 0 for auto-select"}})

(defn- usage-help[]
(status/line :head "Usage help")
(status/line :detail (cli/format-opts {:spec cli-spec :order [:flowstorm :host :bind :port :help]})))

(defn- usage-fail [msg]
(status/line :error msg)
(usage-help)
(System/exit 1))

(defn- parse-opts [args]
(let [opts (cli/parse-opts args {:spec cli-spec
:restrict true
:error-fn (fn [{:keys [msg]}]
(usage-fail msg))})]
(when-let [extra-gunk (-> (meta opts) :org.babashka/cli)]
(usage-fail (str "unrecognized on the command line: " (pr-str extra-gunk))))
opts))


(defn launch-repl [args]
(let [{:keys [flowstorm host bind port help]} (parse-opts args)]
(if help
(usage-help)
(let [aliases (cond-> []
flowstorm (conj "flowstorm"))]
(status/line :head "Launching Clojure nREPL")
(when flowstorm
(status/line :detail "Flowstorm support is enabled"))
(process/exec "clj" (str "-M:1.12:kaocha:nrepl:" (str/join ":" aliases))
"-h" host
"-b" bind
"-p" port)))))

;; Entry points
(defn -main [& args]
(launch-repl args))

(main/when-invoked-as-script
(apply -main *command-line-args*))