[#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]
|
(defn shell-seq [in]
|
||||||
(line-seq (java.io.BufferedReader. in)))
|
(line-seq (java.io.BufferedReader. in)))
|
||||||
|
|
||||||
|
(def version (str/trim (slurp (io/resource "BABASHKA_VERSION"))))
|
||||||
|
|
||||||
(defn print-version []
|
(defn print-version []
|
||||||
(println (str "babashka v"(str/trim (slurp (io/resource "BABASHKA_VERSION"))))))
|
(println (str "babashka v" version)))
|
||||||
|
|
||||||
|
|
||||||
(defn print-help []
|
(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 (str "sci v" (str/trim (slurp (io/resource "SCI_VERSION")))))
|
||||||
(println)
|
(println)
|
||||||
(println "Options must appear in the order of groups mentioned below.")
|
(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/jdbc %s
|
||||||
:feature/postgresql %s
|
:feature/postgresql %s
|
||||||
:feature/hsqldb %s}")
|
:feature/hsqldb %s}")
|
||||||
(str/trim (slurp (io/resource "BABASHKA_VERSION")))
|
version
|
||||||
features/core-async?
|
features/core-async?
|
||||||
features/csv?
|
features/csv?
|
||||||
features/java-nio?
|
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]
|
(defn start-nrepl! [address ctx]
|
||||||
(let [dev? (= "true" (System/getenv "BABASHKA_DEV"))
|
(let [dev? (= "true" (System/getenv "BABASHKA_DEV"))
|
||||||
nrepl-opts (nrepl-server/parse-opt address)
|
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)
|
(nrepl-server/start-server! ctx nrepl-opts)
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(println "For more info visit https://github.com/borkdude/babashka/blob/master/doc/repl.md#nrepl.")))
|
(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)]
|
new-id! #(swap! id inc)]
|
||||||
(testing "session"
|
(testing "session"
|
||||||
(is 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"
|
(testing "eval"
|
||||||
(bencode/write-bencode os {"op" "eval" "code" "(+ 1 2 3)" "session" session "id" (new-id!)})
|
(bencode/write-bencode os {"op" "eval" "code" "(+ 1 2 3)" "session" session "id" (new-id!)})
|
||||||
(let [msg (read-reply in session @id)
|
(let [msg (read-reply in session @id)
|
||||||
id (:id msg)
|
id (:id msg)
|
||||||
value (:value msg)]
|
value (:value msg)]
|
||||||
(is (= 1 id))
|
(is (= 2 id))
|
||||||
(is (= value "6")))
|
(is (= value "6")))
|
||||||
(testing "creating a namespace and evaluating something in it"
|
(testing "creating a namespace and evaluating something in it"
|
||||||
(bencode/write-bencode os {"op" "eval"
|
(bencode/write-bencode os {"op" "eval"
|
||||||
|
|
@ -179,10 +187,13 @@
|
||||||
server-state (atom nil)]
|
server-state (atom nil)]
|
||||||
(try
|
(try
|
||||||
(if tu/jvm?
|
(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
|
(init {:namespaces main/namespaces
|
||||||
:features #{:bb}})
|
:features #{:bb}})
|
||||||
(parse-opt "0.0.0.0:1668"))]
|
nrepl-opts)]
|
||||||
(reset! server-state server))
|
(reset! server-state server))
|
||||||
(let [pb (ProcessBuilder. ["./bb" "--nrepl-server" "0.0.0.0:1668"])
|
(let [pb (ProcessBuilder. ["./bb" "--nrepl-server" "0.0.0.0:1668"])
|
||||||
_ (.redirectError pb ProcessBuilder$Redirect/INHERIT)
|
_ (.redirectError pb ProcessBuilder$Redirect/INHERIT)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue