Fork me on GitHub
#babashka
<
2020-08-29
>
maxp06:08:58

Is it possible to run shell exec in babashka? I'd like to parse edn parameters and than start interactive psql.

borkdude06:08:29

@maxp the closest thing to that is to use ProcessBuilder with inheritIO + wait + System/exit

borkdude06:08:31

See http://book.babashka.org for some examples. Deps.clj uses this to start a REPL

maxp06:08:29

Thank you, I'll try.

borkdude06:08:17

@maxp

bb '(-> (doto (ProcessBuilder. ["clj"]) (.inheritIO)) (.start) (.waitFor) (System/exit))'

borkdude06:08:05

In other news, babashka and sci are being sponsored this quarter by CT: https://www.clojuriststogether.org/news/q3-2020-funding-announcement/

🎉 33
maxp06:08:13

yes (.inheritIO) works!

👍 3
borkdude12:08:25

I added the org.httpkit.server/run-server function to babashka in a branch (see #babashka_circleci_builds), just to experiment. It only adds 0.5MB to the binary.

borkdude13:08:38

(require '[org.httpkit.server :as srv]
         '[clojure.java.browse :as browse])

(defn app [{:keys [:request-method :uri]}]
  (case [request-method uri]
    [:get "/"] {:body "Welcome!"
                :status 200}
    [:get "/foo"] {:body "Foo!"
                   :status 200}))

(srv/run-server app {:port 8080})

(println "8080")
(browse/browse-url "")

@(promise)

🎉 6
💯 6
borkdude13:08:51

OK, if you have more ideas about this, I made an issue here: https://github.com/borkdude/babashka/issues/556

borkdude13:08:31

I guess it could also be implemented as a pod first. Not entirely sure how that would work.

Chase14:08:54

I can't seem to find the editor integration documentation on the github repo anymore. Can someone please point me to the right spot?

borkdude14:08:36

@chase-lambert What do you mean, for babashka nREPL?

Chase14:08:58

Omg, I'm losing my mind. I am reinstalling all your great tools and was thinking of clj-kondo. Lol! Nothing to see here, people!

Chase14:08:31

Thank you. I'll do this after I grab my morning coffee that I apparently really need. haha