This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-08
Channels
- # adventofcode (49)
- # announcements (2)
- # architecture (4)
- # babashka (48)
- # babashka-sci-dev (4)
- # beginners (7)
- # biff (1)
- # calva (14)
- # cider (6)
- # clj-kondo (1)
- # clj-yaml (1)
- # cljsrn (3)
- # clojure (14)
- # clojure-art (12)
- # clojure-europe (62)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (5)
- # clojurescript (18)
- # clr (4)
- # community-development (9)
- # conjure (2)
- # core-async (3)
- # cursive (2)
- # datomic (2)
- # emacs (8)
- # events (3)
- # graalvm (1)
- # helix (6)
- # holy-lambda (3)
- # jobs (1)
- # off-topic (16)
- # polylith (30)
- # practicalli (11)
- # reitit (5)
- # shadow-cljs (14)
- # slack-help (10)
- # xtdb (6)
To make REPL-driven development easier, I'd like to only eval a certain sexp when not in a REPL. Is there an easy way to detect when I'm in a REPL? Apologies if this has been asked and answered; I did a basic search in this channel and didn't find anything.
The idiom for this in babashka is:
(when (= *file* (System/getProperty "babashka.file"))
;; you're not in the REPL
)
The idiom for this in babashka is:
(when (= *file* (System/getProperty "babashka.file"))
;; you're not in the REPL
)
Hey there. I'm trying out babashka.nrepl
but can't seem to figure out how to print on the client.
I have a minimal server setup (sci/binding doesn't seem to be necessary)
(sci/binding [sci/out *out*
sci/in *in*]
(-> (sci/init {:namespaces {'my {'print (fn [] (println "TESTING"))}}})
(babashka.nrepl.server/start-server! {:host "127.0.0.1" :port 23456})))
When I connect with Cider and and run (println 123)
it get properly printed to the client's REPL. But calling (my/print)
prints in the server REPL. Any idea how to fix this?Like this
(-> (sci/init
{:namespaces {'my {'print (fn []
(binding [*out* @sci/out]
(println "TESTING")))}}})
(babashka.nrepl.server/start-server! {:host "127.0.0.1" :port 23456}))
how do you do shell stream editing with babashka? i.e. like you do with sed in bash. In example Iām reaching for bash+sed in cases like this: journalctl -u servicename-$1 -f -o cat | sed 's/(.+servicename\[.+\]:)//'
Love it, can I steal this (or something like it) for How to do things with babashka?
once again improved, please check again. I emphasized streaming https://github.com/babashka/process#processing-streaming-output
@U06F82LES of course!
Is there a way to avoid having to add nil
at the end to skip the gobbldygook at the end?
it was kind of a mistake to print the last expression when executing a file, but when I did a poll most people wanted to keep it ;)
huh interesting - I think it's a little flaw (but doesn't matter in the end)
@U06F82LES reading an entire file into memory is done easier like this:
(:out (shell {:out :string} "cat /etc/hosts"))
š updated the 2nd example
Tangentially I like to split the command and args, because otherwise I get anxious - who does the string splitting again? does it know about single quotes? what if I need to interpolate a variable here? I feel like separate args are simpler in the Hickeyan sense
yeah I know! I did in the snippet
it's all good š
@U06F82LES I thought about changing the printing of the output like 2 years or so ago, but then the Rich Hickey on my shoulder told me that it could be a breaking change...
how do you use the repl when writing code like this? Mine just freezes
or do you use i.e. -x to run the functions?
Please help spread the word on this new babashka article that just appeared on the GraalVM blog :)
> Note that the amount of parens is exactly the same though š. I hope that James Gosling reads that .
(for those of you who were not at reClojure, James Gosling was a keynote speaker and he hinted at his struggles with parens)