Fork me on GitHub
Krishan V11:01:43

Hello everyone, how would I go about removing a tagged literal that comes with the output of babashka.fs functions? I want to write my list of files in an edn but I have hit a blocker with extending my reader to recognise #object[sun.nio.fs.UnixPath . I am not familiar with tagged literals and the reader itself, I can do without them for now, I just need the raw paths to the files.


@krishanvj Just transform them into strings with str

🙌 2
Krishan V11:01:46

Thanks! Appreciate your fast reply

Krishan V13:01:47

I ran into a strange behavior, I have to be missing something obvious here. Why am I always running the truthy path?

(let [[output-dir container-name inside-container?] *command-line-args*]
  (when (or (empty? output-dir) (empty? container-name))
    (System/exit 1))
  (if (true? (boolean inside-container?))
    (println "truthy with these args: " inside-container? )
    (println "falsy")))
I'd always get truthy with these args: true or truthy with these args: false regardless of what I supply as my third argument. Can't reach the falsy path 😞


@krishanvj boolean converts a truthy value into true. Only nil and false are non-truthy values. A string is always a truthy value.


You can use parse-boolean instead, or just write (= "true" inside-container?")


(boolean "false") ;;=> true

Krishan V13:01:58

Just went with the parse-boolean function, is this part of Clojure or only found within babashka for this exact use-case? Thank btw!


it's new in clojure 1.11 alpha4 and already available in bb.

🙌 1
Dimitar Uzunov14:01:44

to prep our CI agents, I need to run a bb.edn file in order for the deps.clj packages be downloaded in the CI user dir. Is there an easier way to “prep” a user for future use of bb?


Just run bb tasks or so should do.

Nick Stares20:01:01

Trying to make an ISO-8601 formatter for AWS. Unfortunately this is giving me my offset time instead of GMT. What am I missing?

(def ISO-8601 (DateTimeFormatter/ofPattern "yyyyMMdd'T'HHmmss'Z'"))
(.format (LocalDateTime/now) ISO-8601)
;; => "20220131T121126Z" (should be GMT, not UTC-8?)


Is the behavior in bb different than in clj?

Nick Stares20:01:44

Oops, it's probably not. I posted here because I was going off your SO example for babashka. Can move to a different channel 😅


No problem, just checking :)


Maybe you need to use a ZonedDateTime?

Nick Stares20:01:46

Ok, I can try that and set the zone to GMT. I'm just confused because I didn't want a zone at all, and I thought LocalDateTime didn't have that, so I'm wondering how it is even getting my local timezone at all


I think it just appends whatever you put in your format string:

user=> (def ISO-8601 (java.time.format.DateTimeFormatter/ofPattern "yyyyMMdd'T'HHmmss'Zxxx'"))
user=> (.format (java.time.LocalDateTime/now) ISO-8601)


> > ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT )


user=> (-> (java.time.ZonedDateTime/now) (.format java.time.format.DateTimeFormatter/ISO_INSTANT))


Is this the right one?

user=> (def ISO-8601 (java.time.format.DateTimeFormatter/ofPattern "yyyyMMdd'T'HHmmss'Z'"))
user=> (-> (java.time.ZonedDateTime/now) (.format ISO-8601))


Or maybe this one:

user=> (-> (java.time.ZonedDateTime/now java.time.ZoneOffset/UTC ) (.format ISO-8601))

🎉 1
Nick Stares20:01:40

Ah that's the one! Wow thank you so much 😍

👍 1

A question about getting output from a babashka process: I have a subprocess that needs to print things to stdout, but it produces a value I want to get back. What’s a good way to get the value back out of it? I am considering passing a file path, and watching the file path from the caller… is this such a good idea though? 😅



(-> (babashka.process/process ["foo"] {:out :string}) deref :out)

👀 1

Thanks, I ended up using stderr to send back the result.


so it would look like:

(-> (babashka.process/process ["foo"] {:err :string :inherit true}) deref :err)


Cool! Honestly I would do it the other way around, send questions over stderr and send data over stdout, but inquirer JS might already send over stdout, so then that's not an option


stderr is usually for warnings, side information, stdout is the real data you want from a program


but it's just a convention


yea that is true, maybe I can redirect it to use stderr


the thing is, inquirer doesn’t work very well when speaking in stderr, missing colors etc


yeah, then what you had first was probably the right call, or a file as you said


perhaps you can call your program with an optional output file argument


I was considering it, if there are actual instances of stderr coming through I will switch to that. Thanks for all your help today!!


can you print things to stderr and put the return value in stdout?

David Pham21:01:40

Babashka is now installed in circle ci image!!

🆒 4
David Pham21:01:46

✔️ 1
🥳 2