This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-10
Channels
- # announcements (6)
- # architecture (2)
- # babashka (30)
- # beginners (90)
- # calva (21)
- # cider (22)
- # clj-kondo (27)
- # cljs-dev (7)
- # clojure (132)
- # clojure-europe (51)
- # clojure-nl (12)
- # clojure-norway (3)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (69)
- # cloverage (9)
- # conjure (5)
- # core-async (54)
- # cursive (14)
- # datomic (34)
- # emacs (7)
- # fulcro (10)
- # graalvm (40)
- # graalvm-mobile (2)
- # gratitude (2)
- # improve-getting-started (1)
- # introduce-yourself (1)
- # jobs-discuss (61)
- # leiningen (5)
- # malli (6)
- # off-topic (59)
- # pathom (11)
- # polylith (38)
- # reagent (3)
- # reitit (3)
- # rewrite-clj (3)
- # shadow-cljs (53)
- # tools-build (35)
- # transit (8)
- # vim (62)
- # web-security (26)
- # xtdb (4)
Concerning dependent tasks: Am I right in that the return-value of a task can be accessed via its name in the :depends-array - like -jar-file
in
jar {:depends [-target -jar-file]
:task (when (seq (fs/modified-since -jar-file
(fs/glob "src" "**.clj")))
(spit -jar-file "test")
(println "made jar!"))}
?Idea. When running multiple babashka tasks in parallell, I'd love to see a prefix + coloring to differentiate between output from the different parallel processes. I think Docker Compose does something similar. Kind of hard to know which log line is from with process otherwise. Not sure if this makes sense to provide as functionality from the task runner itself, or if it can just be a "wrapper" / "function" / something in "userspace" that we could write and change ourself.
Good idea, but not sure how feasible this is. This requires several changes on several levels. All printing to stdout should be intercepted from normal println
as well as processes invoked with babashka.process, clojure.java.shell, ProcessBuilder, etc.
Hmm, there is https://docs.oracle.com/javase/6/docs/api/java/lang/System.html#setOut%28java.io.PrintStream%29 which might work for this.
Yes I've been meaning to use parallel tasks in some smaller projects. But at work I use foreman for running databases and it can get quite chatty in the logs, so the colored output helps. The Procfile runs 2 apps and 3 DBs and it needs various env vars set to work correctly, which would be cleaner if it was just a babashka task or script
As a current solution: possibly there is a bash/unix programs which can prepend the output of a process with some prefix/color, which you can then use to compose in babashka.process?
I guess this works:
yes | while read line; do echo "[ERROR] $line"; done
and you could wrap that while read in a babashka script even.Will give that a try. Of course I could just consume the output of the process and prepend to each line. Since the --config flag was added I've been meaning to give that a try
I got the above from : https://serverfault.com/questions/72744/command-to-prepend-string-to-each-line yeah, indeed, same idea.
I think you could solve this at the babashka process level by manually handling the output, although it would be nice if babashka process had something like this built-in. (process ["foo" "bar"] {:color :green :prepend "FOO"})
and then shell
in tasks could also have that (since it's just a wrapper around process)
Here's a snippet from what I'm doing right now. frontend
is a normal bash function that runs the frontend.
Essentially, with_prefix
is meant to be used as a pipe that takes either stdout or stderr as input, and "colors and adds prefixes" as required.
(sorry I kind of fired off a question and went dark, I have a hard time keeping focus on what I'm working on right now unless I turn off Slack)
@teodorlu Awesome, yeah, that's kind of what would become an option in babashka process (and could be done manually now by processing lines of output in babashka process).
Quickly skimmed the https://github.com/babashka/process, really like the process
, deref
and check
API. Intresting fusion of unixy and lispy design.
@teodorlu regarding use of color in bb output, I remember seeing that @lee did something cool in rewrite-clj with :enter
and :leave
tasks where every task got a nice colorized task started, task done. https://github.com/clj-commons/rewrite-clj/blob/main/bb.edn#L13-L14. Your questions reminded me of that.
What I do is bb some-file.clj | puget
- this works great if your babashka script outputs edn data
Yeah, https://github.com/lread/status-line is really just targeted for creating heading, warnings, and errors that pop out.