Fork me on GitHub
#babashka
<
2023-03-07
>
danieroux09:03:33

It does not seem that carve honours the .carve/config.edn - only the opts gets passed on here? - https://github.com/borkdude/carve/blob/master/src/carve/api.clj#L64

borkdude09:03:59

opts aren't merged

borkdude09:03:19

there was a reason for this, you can maybe find it in one of the issues

danieroux09:03:24

We're not seeing this behaviour: "When invoking carve with no options, the options in .carve/config.edn will be used." on https://github.com/borkdude/carve#options

borkdude09:03:06

can you file an issue with a repro? there might be a bug in there. PR also welcome

danieroux09:03:39

What's the expected from you? opts and config are exclusive, not merged?

borkdude09:03:09

isn't your issue that your config file isn't loaded at all?

borkdude09:03:23

whether opts should be merged is a different question

borkdude09:03:58

we can of course revisit this

danieroux10:03:55

:merge-config solves our immediate problem

borkdude11:03:32

Merged, thank you

2
borkdude16:03:16

🎉 4
👍 6
joakimen18:03:01

Is there a neat way to redirect stderr to stdout/combine them using https://github.com/babashka/process (when returning as a string)? Often finding myself wanting to just return the exit-code and message, regardless of it being a success or failure, then having to check both :out and :err and return wherever the called program has decided to put their output

borkdude18:03:39

@U0422G22932 sure, (sh "ls")

👀 2
joakimen18:03:44

I’ve used that a load. I might be confused here, but this is how it behaves

(p/sh "cat idontexist")
{:proc #object[java.lang.ProcessImpl 0x6b373678 "Process[pid=87133, exitValue=1]"],
 :exit 1,
 :in
 #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x14f5a7ae "java.lang.ProcessImpl$ProcessPipeOutputStream@14f5a7ae"],
 :out "",
 :err "cat: idontexist: No such file or directory\n",
 :prev nil,
 :cmd ["cat" "idontexist"]}
I usually do something like (-> (p/sh "cat idontexist") :err) to get the message, but then I obviously have to know/check whether the output is in :err or :out

borkdude18:03:25

you can redirect :out and :err to the same stringwriter and then call str on that stringwriter

borkdude18:03:44

but you might get output that's mixed up between stdout and stderr, so personally I'd just avoid doing that

borkdude18:03:42

is your goal to eventually print the output? then why not just use shell?

joakimen18:03:54

Usually it’s been when I fire off several commands using pmap or future, then just want to return the result of each invocation as a map, like {:task "my-async-task" :exit (:exit proc) :message (stderr or stdout)} It’s more if I want to gather the results and do something with it, than to dump out everything

joakimen18:03:49

so now I just check :exit and look at the appropriate key and return that, was just wondering if there was a shortcut for lazy people 🙂

borkdude18:03:06

out and err are not mutually exclusive

borkdude18:03:31

so no, there is no shortcut

joakimen18:03:26

Alright, thanks for answering!