Say, I see planck uses fipp for printing stuff out. Is there any way I can include it in my own planck script? Trying to come up with a fast EDN pretty-printer
yeah
(I tried a simple (require) but no dice)
Hrm… you are perhaps trying fipp.edn
? Planck doesn’t bundle that particular namespace
Aha, that's what I was trying
If you are just trying to pretty-print like Planck does, perhaps planck.pprint.data
which uses FIPP might get you what you want. (It is an internal namespace, but it could at least let you see if it leads to something.)
I suppose I could just (eval)
the data and print it from planck, it's from trusted sources
Ok, cool, I will give that a try, thanks
@timgilbert: Yeah, if you just want to read in some stuff to print nicely in the planck terminal you can, for example:
(cljs.tools.reader/read-string ":a”)
You could combine that with slurp:
(-> (planck.core/slurp "foo.edn")
cljs.tools.reader/read-string)
@timgilbert: If you just want to pretty-print stdin using Planck, try this:
$ echo "[1 2 3]" | planck -e"(require 'planck.pprint.data 'planck.themes 'cljs.tools.reader 'planck.core)" -e'(-> (planck.core/slurp planck.core/*in*) cljs.tools.reader/read-string (planck.pprint.data/pprint {:width 70 :theme (planck.themes/get-theme :light)}))'
(You need to use Planck 1.16 for the above to work.)
Awesome, thanks @mfikes
My script version of that is:
#! /usr/bin/env planck
(ns edn.pprint
(:require [planck.pprint.data :as d]
[planck.themes :as themes]
[cljs.tools.reader :as reader]
[planck.core :as core]))
(-> (core/slurp core/*in*)
reader/read-string
(d/pprint {:width 70 :theme (themes/get-theme "light")}))
Will probably elaborate on it from there
@timgilbert: I'll add a ticket to Planck to bundle all of the Fipp namespaces. Also, if Planck's color syntax highlighting proves to be useful outside of the REPL, it could be surfaced in namespaces intended for public consumption.
That would be cool
I actually don't seem to be able to get the syntax highlighting to work in the above script, though it does at the repl, will look into it later
Oh, duh - I used "light" instead of :light