babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
coby 2020-09-13T18:11:26.198600Z

Hey there, is it possible to get Babashka to pretty-print stuff using spit or similar?

#!/usr/bin/env bb

(binding [*print-pretty* true]
  (spit "something.edn" {:pretty {:printed :structure}}))

;; clojure.lang.ExceptionInfo: Could not resolve symbol: *print-pretty* [at /home/tamayo/projects/bread-cms/bin/bread, line 3, column 13]

borkdude 2020-09-13T18:13:35.199200Z

Currently no, this is the first time I'm seeing this variable.

borkdude 2020-09-13T18:14:27.199700Z

You can post an issue about this with some examples about what this does. I haven't used it in my 10 years of Clojure :)

borkdude 2020-09-13T18:15:54.200Z

Does this impact spit in normal Clojure?

coby 2020-09-13T18:17:01.200200Z

I think so, checking...

dpsutton 2020-09-13T18:21:53.200900Z

/tmp ❯❯❯ cd stuff
/t/stuff ❯❯❯ clj
Clojure 1.10.1
(binding [*print-pretty* true]
  (spit "something.edn" {:pretty {:printed :structure}}))
Syntax error compiling var at (REPL:1:1).
Unable to resolve var: *print-pretty* in this context
user=>

borkdude 2020-09-13T18:22:28.201300Z

@dpsutton I think that var is coming from clojure.pprint

coby 2020-09-13T18:22:36.201600Z

yeah

coby 2020-09-13T18:22:39.201900Z

just realized that

coby 2020-09-13T18:23:28.202400Z

but it doesn't solve my problem anyway, because it's already true

coby 2020-09-13T18:24:11.203500Z

what I want is to display write EDN maps on multiple lines, which apparently it doesn't do. So I'll keep digging!

borkdude 2020-09-13T18:24:29.203900Z

@ctamayo you can use (binding [*out* (io/writer your-file)] (pprint edn)) to write pretty to a file

coby 2020-09-13T18:31:16.205Z

hmm, that is printing to stdout for me, and writing an empty file

#!/usr/bin/env bb

(ns systems.bread.alpha.cli
  (:require
   [<http://clojure.java.io|clojure.java.io> :as io]
   [clojure.pprint :as pp]))

(defn write! [path content]
  (binding [*out* (io/writer path)]
    (pp/pprint content)))

(write! "something.edn" {:some :edn})

; $ bin/bread 
; {:some :edn}

borkdude 2020-09-13T18:32:14.205300Z

hmm, let me try in normal clojure. could be a bug

coby 2020-09-13T18:33:35.205700Z

yeah, working for me in clj

borkdude 2020-09-13T18:33:37.205800Z

Seems to work both in clj and bb here. What's your bb version?

coby 2020-09-13T18:33:47.206100Z

oh ha

coby 2020-09-13T18:34:51.206800Z

oh wow, it is embarrassingly old ... v0.0.86 😛

borkdude 2020-09-13T18:35:34.207Z

ok, try 0.2.0

coby 2020-09-13T18:37:24.207300Z

working now, thanks! Sorry for the trouble!

borkdude 2020-09-13T18:37:56.207500Z

np :)

Jakub Holý 2020-09-13T22:06:14.210200Z

Hi! Is it still so that the Cognitect aws api cannot be compiled to GraalVM native binary? Id like to make a bb aws lambda (quick cold start) but need to write to S3... Thanks!

borkdude 2020-09-13T22:07:21.210700Z

@holyjak yes. it's a recurring topic :) you can read a recent discussion about this here: https://clojurians.slack.com/archives/CLX41ASCS/p1599750635174200

👍 1