Add middleware arg #1529
This commit is contained in:
parent
d3f7a52f65
commit
dbb28b86e1
2 changed files with 14 additions and 4 deletions
|
|
@ -313,8 +313,11 @@ Use bb run --help to show this help output.
|
||||||
(defn start-socket-repl! [address ctx]
|
(defn start-socket-repl! [address ctx]
|
||||||
(socket-repl/start-repl! address ctx))
|
(socket-repl/start-repl! address ctx))
|
||||||
|
|
||||||
(defn start-nrepl! [address]
|
(defn start-nrepl! [user-middleware address]
|
||||||
(let [opts (nrepl-server/parse-opt address)]
|
(let [user-middleware (when-not (str/blank? user-middleware)
|
||||||
|
(read-string user-middleware))
|
||||||
|
opts (nrepl-server/parse-opt address)
|
||||||
|
opts (assoc opts :user-middleware user-middleware)]
|
||||||
(babashka.impl.nrepl-server/start-server! opts))
|
(babashka.impl.nrepl-server/start-server! opts))
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(println "For more info visit: https://book.babashka.org/#_nrepl"))
|
(println "For more info visit: https://book.babashka.org/#_nrepl"))
|
||||||
|
|
@ -645,6 +648,11 @@ Use bb run --help to show this help output.
|
||||||
(recur options
|
(recur options
|
||||||
(assoc opts-map
|
(assoc opts-map
|
||||||
:nrepl (or opt "1667"))))
|
:nrepl (or opt "1667"))))
|
||||||
|
("--middlware")
|
||||||
|
(let [options (next options)]
|
||||||
|
(recur (next options)
|
||||||
|
(assoc opts-map
|
||||||
|
:middleware (first options))))
|
||||||
("--eval", "-e")
|
("--eval", "-e")
|
||||||
(let [options (next options)
|
(let [options (next options)
|
||||||
opts-map (assoc opts-map :prn true)]
|
opts-map (assoc opts-map :prn true)]
|
||||||
|
|
@ -839,7 +847,7 @@ Use bb run --help to show this help output.
|
||||||
:main :uberscript :describe?
|
:main :uberscript :describe?
|
||||||
:jar :uberjar :clojure
|
:jar :uberjar :clojure
|
||||||
:doc :run :list-tasks
|
:doc :run :list-tasks
|
||||||
:print-deps :prepare]
|
:print-deps :prepare :middleware]
|
||||||
exec-fn :exec}
|
exec-fn :exec}
|
||||||
cli-opts
|
cli-opts
|
||||||
print-result? (:prn cli-opts)
|
print-result? (:prn cli-opts)
|
||||||
|
|
@ -1018,7 +1026,7 @@ Use bb run --help to show this help output.
|
||||||
describe?
|
describe?
|
||||||
[(print-describe) 0]
|
[(print-describe) 0]
|
||||||
repl [(repl/start-repl! sci-ctx) 0]
|
repl [(repl/start-repl! sci-ctx) 0]
|
||||||
nrepl [(start-nrepl! nrepl) 0]
|
nrepl [(start-nrepl! middleware nrepl) 0]
|
||||||
uberjar [nil 0]
|
uberjar [nil 0]
|
||||||
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
||||||
print-deps [(print-deps/print-deps (:print-deps-format cli-opts)) 0]
|
print-deps [(print-deps/print-deps (:print-deps-format cli-opts)) 0]
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
(deftest parse-opts-test
|
(deftest parse-opts-test
|
||||||
(is (= "1667"
|
(is (= "1667"
|
||||||
(:nrepl (parse-opts ["--nrepl-server"]))))
|
(:nrepl (parse-opts ["--nrepl-server"]))))
|
||||||
|
(is (= "[foo]"
|
||||||
|
(:middleware (parse-opts ["--middlware" "[foo]"]))))
|
||||||
(is (= "1666"
|
(is (= "1666"
|
||||||
(:socket-repl (parse-opts ["--socket-repl"]))))
|
(:socket-repl (parse-opts ["--socket-repl"]))))
|
||||||
(is (= {:nrepl "1667", :classpath "src"}
|
(is (= {:nrepl "1667", :classpath "src"}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue