Fork me on GitHub
flowthing05:10:26 (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
🎉 5
🆒 1

This is great!

Rupert (All Street)10:10:16

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


pp works in bb

$ rlwrap bb -Sdeps '{:deps {io.github.eerohele/pp {:git/tag "2023-10-05.5", :git/sha "7059eec"}}}'
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])
user=> (pp/pprint {:a 1 :b 2 :c 3 :d 4} {:max-width 10})
{:a 1,
 :b 2,
 :c 3,
 :d 4}

👍 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.


of course there! (brb)


$ 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}


@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 | epp` etc)


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.


@U04V15CAJ Good idea, thanks! Will add. 👍


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:


@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.


we now use it on (for clj, not cljs)


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


please do 🙂

thanks 1