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]
Currently no, this is the first time I'm seeing this variable.
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 :)
Does this impact spit in normal Clojure?
I think so, checking...
/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=>
@dpsutton I think that var is coming from clojure.pprint
yeah
just realized that
but it doesn't solve my problem anyway, because it's already true
what I want is to display write EDN maps on multiple lines, which apparently it doesn't do. So I'll keep digging!
@ctamayo you can use (binding [*out* (io/writer your-file)] (pprint edn))
to write pretty to a file
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}
hmm, let me try in normal clojure. could be a bug
yeah, working for me in clj
Seems to work both in clj and bb here. What's your bb version?
oh ha
oh wow, it is embarrassingly old ... v0.0.86 😛
ok, try 0.2.0
working now, thanks! Sorry for the trouble!
np :)
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!
@holyjak yes. it's a recurring topic :) you can read a recent discussion about this here: https://clojurians.slack.com/archives/CLX41ASCS/p1599750635174200