Fork me on GitHub
#announcements
<
2023-10-05
>
flowthing05:10:26

https://github.com/eerohele/pp (v2023-10-05.5) is a pretty fast, single-namespace, no-dependency lib for pretty-printing Clojure/EDN data (not code). It is primarily meant for tools that need to pretty-print Clojure evaluation results, but might be useful any time you need to pretty-print something fast.

❤️ 19
2
🎉 5
🆒 1
pesterhazy07:10:12

This is great!

Rupert (All Street)10:10:16

Small ✔️ , fast ✔️ , zero dependency ✔️. Looks good to me!

borkdude16:10:07

pp works in bb

$ rlwrap bb -Sdeps '{:deps {io.github.eerohele/pp {:git/tag "2023-10-05.5", :git/sha "7059eec"}}}'
Cloning: 
Checking out:  at 5f7c68b70aea31561df62d0a56d8396dae8cc9d0
Babashka v1.3.185-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[me.flowthing.pp :as pp])
nil
user=> (pp/pprint {:a 1 :b 2 :c 3 :d 4} {:max-width 10})
{:a 1,
 :b 2,
 :c 3,
 :d 4}
nil
babashka

👍 1
babashka 4
Rupert (All Street)16:10:20

Is there a bb way to call pp as a oneline bash call? Taking raw EDN from standard in and pretty printing it to standard out.

borkdude16:10:01

of course there! (brb)

borkdude16:10:18

$ bb '(zipmap (range 10 ) (range 10))' | 
  bb -Sdeps '{:deps {io.github.eerohele/pp {:git/tag "2023-10-05.5", :git/sha "7059eec"}}}' -e "((requiring-resolve 'me.flowthing.pp/pprint) (clojure.edn/read-string (slurp *in*)) {:max-width 5})"
{0 0,
 7 7,
 1 1,
 4 4,
 6 6,
 3 3,
 2 2,
 9 9,
 5 5,
 8 8}

borkdude16:10:44

@U4ZDX466T Maybe good to add to non-goals: colored output (assuming you don't want this)

Rupert (All Street)16:10:50

It works! Excellent I've added this as a an alias epp to my bash

alias epp='bb -Sdeps '"'"'{:deps {io.github.eerohele/pp {:git/tag "2023-10-05.5", :git/sha "7059eec"}}}'"'"' -e "((requiring-resolve '"'"'me.flowthing.pp/pprint) (clojure.edn/read-string (slurp *in*)) {:max-width 5})"'
bb '(zipmap (range 10 ) (range 10))' | epp
{0 0,
 7 7,
 1 1,
 4 4,
 6 6,
 3 3,
 2 2,
 9 9,
 5 5,
 8 8}

Rupert (All Street)17:10:06

Will be very handy for working with EDN from REST and in files. (`curl https://example.com/abc.edn | epp` etc)

flowthing17:10:23

Heh, pp does seem to work in bb, yes. 👍 The tests have some Clojure-specific things (as well as Transcriptor, which is Clojure-only), but those shouldn't be too difficult to sort out. I have an issue on that.

flowthing17:10:49

@U04V15CAJ Good idea, thanks! Will add. 👍

flowthing17:10:33

Although I suppose I could also release Tab's syntax highlighter as a standalone lib... that would make it pretty straightforward to add color support, too. Would just need to make it output ANSI escape sequences in addition to Hiccup/HTML. :thinking_face:

borkdude17:10:32

@UJVEQPAKS jet also does this btw (and it outputs colorized output) #CM5HRADAA

👍 1
Rupert (All Street)19:10:00

Nice! I'll put that to use too.

mpenet14:10:53

we now use it on https://github.com/exoscale/lingo (for clj, not cljs)

flowthing14:10:56

Cool, thanks for letting me know! Appreciate it. 🙂 Mind if I add that in pp's README?

mpenet14:10:09

please do 🙂

thanks 1