This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-15
Channels
- # announcements (1)
- # babashka (21)
- # beginners (23)
- # biff (8)
- # boot (1)
- # cider (4)
- # clerk (21)
- # clj-kondo (31)
- # clojure (60)
- # clojure-brasil (5)
- # clojure-europe (20)
- # clojurescript (21)
- # datomic (14)
- # graalvm (10)
- # honeysql (1)
- # hoplon (4)
- # hyperfiddle (42)
- # introduce-yourself (1)
- # leiningen (1)
- # lsp (53)
- # pathom (4)
- # releases (2)
- # scittle (24)
- # shadow-cljs (3)
- # xtdb (4)
Hey guys 🙂
Got a few questions on bb hope somebody could help out by answering 🙏
1. Is it possible to work on babashka code with a REPL? i.e. live-coding and sending code to the REPL for inspection? I am developing with Cursive atm so if theres an easy integration for that I would like to know (probably need to configure a new REPL I suppose)
2. Also, what is the design philosophy behind babashka/fs
? does it aim to have full coverage over filesystem APIs, or is it just some useful subset of those? I guess it has the things that the author deems most useful to have for scripting, is that the case?
@UDHL22ZFE 1. Absolutely! https://cursive-ide.com/userguide/babashka.html 2. The use cases in babashka.fs are driven by whatever comes up in the area of file system manipulation. What you're seeing there is what has come up so far
@U04V15CAJ Awesome! thanks :hugging_face:
@U04V15CAJ I got around to trying this out!
I followed the guide: installed deps and configured the BB repl
It just works! 🥳
All I did with it this time was just use fs/list-dir
to show me the files on my home directory and then call count
on it to let me know how many files/dirs there are.
It's important for me to set this up ahead of time for when I would need to write something quickly and won't have time to bother with tooling
Thanks for your help! :hugging_face:
Hey, probably a stupid question or I'm doing something dumb. I have a little personal project that I run against a webserver at home. The web server runs all the time on port 7229, but when I'm running it in debug mode it runs on 7145 (so I can have both at the same time). So in my front end I have a
(def port 7145)
Which I use when building the API call URLS.
I'm writing a release bash script which will build my backend, build my front end and copy it over to the correct folder on my machine. I'd like to first as a step in though to update my settings.cljs file and change (def port 7145)
to (def port 7229)
.
Is their an easy way to do this in babashka, or any other tool I might be missing that will let me easy change some clojure source? I can read the whole file in, find that text and replace it and write it back out again, but I'm sure there must be an easier way / this must be a solved problem already 😄@U013YN3T4DA In ClojureScript you can use this: https://cljs.github.io/api/compiler-options/closure-defines
If you want to do it with rewriting, you can simply use str/replace
and put some recognizable comments around it which you could use in a regex, I've done this in several libraries
oooh rewrite-clj looks cool. ANd zippers is on my backlog to learn, so that's an excuse (prod) to get tothat!
Thanks again for your help on this. I wrote a little script that finds my (def port ) and rewrites it to the release port using babashka and re-write-clj, works perfectly. rewrite-clj is so neat!
I am a newbie trying to write a script that reads a bunch of lines via pipe from stdin and for each line requires additional input from the user, but I cannot figure it out ... When I slurp the entire input to iterate over it later, the stream gets closed. When I try to do both things in the same lineseq the read-line call reads from the piped stdin. So I assume that if there is no call to interject a read-line specifically from tty, I would need some way to read the input and not close stdin, although that of course would be somewhat more inefficient. I would really appreciate some help ...
I remember using /dev/tty
as a read source when I need to read all of stdin and then prompt the user for something in a go program I wrote a while ago.
Here's a very rough babashka script that does the same:
#!/usr/bin/env bb
(ns stdin
(:require [ :as io]
[clojure.string :as string]))
(when (= *file* (System/getProperty "babashka.file"))
(let [in-lines (map string/trim (string/split-lines (slurp *in*)))
tty (io/reader (io/file "/dev/tty"))]
(binding [*in* tty]
(doseq [line in-lines]
(println line)
(println "Keep this line?")
(if (string/includes? (string/lower-case (read-line)) "y")
(println " keeping")
(println " discarding"))
(println "--------------------------------------")))))