[#471] add version info to nrepl describe op
This commit is contained in:
parent
7c4722d66e
commit
6bd3dc3d9f
3 changed files with 23 additions and 8 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit a0996a1654459ee69032a8a3afd41c080fb4a729
|
||||
Subproject commit 0ee3c85e734e26fde1cbf78fb64b84a678831c13
|
||||
|
|
@ -206,12 +206,14 @@
|
|||
(defn shell-seq [in]
|
||||
(line-seq (java.io.BufferedReader. in)))
|
||||
|
||||
(def version (str/trim (slurp (io/resource "BABASHKA_VERSION"))))
|
||||
|
||||
(defn print-version []
|
||||
(println (str "babashka v"(str/trim (slurp (io/resource "BABASHKA_VERSION"))))))
|
||||
(println (str "babashka v" version)))
|
||||
|
||||
|
||||
(defn print-help []
|
||||
(println (str "Babashka v" (str/trim (slurp (io/resource "BABASHKA_VERSION")))))
|
||||
(println (str "Babashka v" version))
|
||||
;; (println (str "sci v" (str/trim (slurp (io/resource "SCI_VERSION")))))
|
||||
(println)
|
||||
(println "Options must appear in the order of groups mentioned below.")
|
||||
|
|
@ -264,7 +266,7 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
|||
:feature/jdbc %s
|
||||
:feature/postgresql %s
|
||||
:feature/hsqldb %s}")
|
||||
(str/trim (slurp (io/resource "BABASHKA_VERSION")))
|
||||
version
|
||||
features/core-async?
|
||||
features/csv?
|
||||
features/java-nio?
|
||||
|
|
@ -303,7 +305,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
|||
(defn start-nrepl! [address ctx]
|
||||
(let [dev? (= "true" (System/getenv "BABASHKA_DEV"))
|
||||
nrepl-opts (nrepl-server/parse-opt address)
|
||||
nrepl-opts (assoc nrepl-opts :debug dev?)]
|
||||
nrepl-opts (assoc nrepl-opts
|
||||
:debug dev?
|
||||
:describe {"versions" {"babashka" version}})]
|
||||
(nrepl-server/start-server! ctx nrepl-opts)
|
||||
(binding [*out* *err*]
|
||||
(println "For more info visit https://github.com/borkdude/babashka/blob/master/doc/repl.md#nrepl.")))
|
||||
|
|
|
|||
|
|
@ -54,12 +54,20 @@
|
|||
new-id! #(swap! id inc)]
|
||||
(testing "session"
|
||||
(is session))
|
||||
(testing "describe"
|
||||
(bencode/write-bencode os {"op" "describe" "session" session "id" (new-id!)})
|
||||
(let [msg (read-reply in session @id)
|
||||
id (:id msg)
|
||||
versions (:versions msg)
|
||||
babashka-version (bytes->str (get versions "babashka"))]
|
||||
(is (= 1 id))
|
||||
(is (= main/version babashka-version))))
|
||||
(testing "eval"
|
||||
(bencode/write-bencode os {"op" "eval" "code" "(+ 1 2 3)" "session" session "id" (new-id!)})
|
||||
(let [msg (read-reply in session @id)
|
||||
id (:id msg)
|
||||
value (:value msg)]
|
||||
(is (= 1 id))
|
||||
(is (= 2 id))
|
||||
(is (= value "6")))
|
||||
(testing "creating a namespace and evaluating something in it"
|
||||
(bencode/write-bencode os {"op" "eval"
|
||||
|
|
@ -179,10 +187,13 @@
|
|||
server-state (atom nil)]
|
||||
(try
|
||||
(if tu/jvm?
|
||||
(let [server (start-server!
|
||||
(let [nrepl-opts (parse-opt "0.0.0.0:1668")
|
||||
nrepl-opts (assoc nrepl-opts
|
||||
:describe {"versions" {"babashka" main/version}})
|
||||
server (start-server!
|
||||
(init {:namespaces main/namespaces
|
||||
:features #{:bb}})
|
||||
(parse-opt "0.0.0.0:1668"))]
|
||||
nrepl-opts)]
|
||||
(reset! server-state server))
|
||||
(let [pb (ProcessBuilder. ["./bb" "--nrepl-server" "0.0.0.0:1668"])
|
||||
_ (.redirectError pb ProcessBuilder$Redirect/INHERIT)
|
||||
|
|
|
|||
Loading…
Reference in a new issue