This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-03
Channels
- # announcements (4)
- # aws (13)
- # babashka (35)
- # beginners (162)
- # boot (8)
- # calva (5)
- # chlorine-clover (15)
- # cider (64)
- # clj-kondo (20)
- # cljs-dev (29)
- # clojars (6)
- # clojure (166)
- # clojure-europe (3)
- # clojure-finland (6)
- # clojure-france (8)
- # clojure-germany (3)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-spec (49)
- # clojure-uk (83)
- # clojurescript (39)
- # clojurex (5)
- # core-typed (2)
- # cursive (3)
- # data-science (17)
- # datascript (3)
- # datomic (22)
- # exercism (5)
- # fulcro (3)
- # jobs-discuss (2)
- # joker (2)
- # kaocha (3)
- # malli (26)
- # off-topic (89)
- # pathom (10)
- # pedestal (14)
- # protorepl (14)
- # re-frame (23)
- # reitit (2)
- # shadow-cljs (27)
- # slack-help (10)
- # spacemacs (14)
- # tools-deps (10)
- # tree-sitter (3)
- # xtdb (19)
- # yada (2)
H! 👋 I started playing with babashka today and I was wondering how I can use stdin via *input*
, but if no input is provided show a usage message. It seems that babashka blocks on *input*
when nothing is "piped" into it. Is there a way to detect if input has been provided before reading it or should I think about this in a different way?
$ bb '(pos? (.available System/in))'
false
$ echo true | bb '(pos? (.available System/in))'
true
made an issue for it: https://github.com/borkdude/babashka/issues/324
Thanks @borkdude! Another question. Should (System/exit 1)
end the process? Because that is not the case atm.
@briemens interesting. normally it should:
$ bb '(loop [] (System/exit 1) (recur))'; echo $?
1
often it's also good to check if something works on the JVM / clojure to see if it's an issue with bb or not
The reason why I'm asking is because the emacs inf-clojure
mode breaks because of this. It attempts to identify which type of REPL it's in by running a series of forms like:
I'll make an issue out of it, we'll see if I can figure out a fix within reasonable company time ;)
@rovanion the fix I propose is adding a check if the namespace exists: https://github.com/borkdude/sci/blob/0e011ddb4d435dfebe6c9cf0547e26244d77aec7/src/sci/impl/namespaces.cljc#L312
or maybe that check should rather be added here: https://github.com/borkdude/sci/blob/0e011ddb4d435dfebe6c9cf0547e26244d77aec7/src/sci/impl/utils.cljc#L132
Right, here are the forms.
;;;; Lumo
;;;; ====
(defcustom inf-clojure--lumo-repl-form
"(find-ns 'lumo.repl)"
"Form to invoke in order to verify that we launched a Lumo REPL."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))
;;;; Planck
;;;; ====
(defcustom inf-clojure--planck-repl-form
"(find-ns 'planck.repl)"
"Form to invoke in order to verify that we launched a Planck REPL."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))
;;;; Joker
;;;; ====
(defcustom inf-clojure--joker-repl-form
"(find-ns 'joker.repl)"
"Form to invoke in order to verify that we launched a Joker REPL."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))
Below is the test where the forms are used:
(defun inf-clojure--detect-repl-type (proc)
"Identifies the current REPL type for PROC."
(when (not inf-clojure--repl-type-lock)
(let ((inf-clojure--repl-type-lock t))
(cond
((inf-clojure--some-response-p proc inf-clojure--lumo-repl-form) 'lumo)
((inf-clojure--some-response-p proc inf-clojure--planck-repl-form) 'planck)
((inf-clojure--some-response-p proc inf-clojure--joker-repl-form) 'joker)
(t 'clojure)))))
if you want to preview the new nREPL server support, go to #babashka_circleci_builds and get a binary from the nrepl-server
branch.
report any issues to https://github.com/borkdude/babashka/issues/301
@rovanion I pushed a fix for 325 to master. The binary should appear within a minute or 10 in #babashka_circleci_builds
I merged the nREPL server to master now.
To try it out, grab any of these binaries and run with ./bb --nrepl-server 1667
. Rolling out a release this weekend.
[linux - nrepl-server@56cfed11d265f69cdf228428e80c69dbe6fc7937]: https://6022-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.79-SNAPSHOT-linux-amd64.zip
[macos - nrepl-server@56cfed11d265f69cdf228428e80c69dbe6fc7937]: https://6020-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.79-SNAPSHOT-macos-amd64.zip