planck

Planck ClojureScript REPL
2016-10-19T13:16:34.000368Z

is there a way to use planck like jq . to pretty format edn output? e.g.

curl -H “Accept: application/edn” <https://service/stuff> | planck

mfikes 2016-10-19T13:17:19.000371Z

Yes. But, because we are not on paid Slack, we can’t scroll back to see the solution 😞

mfikes 2016-10-19T13:18:05.000372Z

(It involved using Planck’s pretty printer. That solution could be reconstructed.)

mfikes 2016-10-19T13:32:32.000373Z

@rafaelzlisboa

echo "[1 2 3]" | planck -e"(require 'planck.pprint.data 'planck.themes 'cljs.tools.reader 'planck.core)" -e'(-&gt; (planck.core/slurp planck.core/*in*) cljs.tools.reader/read-string (planck.pprint.data/pprint {:width 70 :theme (planck.themes/get-theme :light)}))’
Note: Not guaranteed to always work in the future because this is using some internal Planck namespaces. (from https://clojurians-log.clojureverse.org/planck/2016-08-18.html)

👍 1
2016-10-19T15:47:56.000374Z

@mfikes how would you feel about having a --pretty-print option for this?

mfikes 2016-10-19T15:49:37.000375Z

@rafaelzlisboa I think it is fine to use Planck to create ClojureScript programs that can pretty print. It would feel wrong to me for Planck itself to have options for any specific application.

2016-10-19T15:50:06.000376Z

makes total sense to me. thanks!

mfikes 2016-10-19T15:50:53.000377Z

@rafaelzlisboa See Tim Gilbert’s script version of the above in the link. You could make a pp script or somesuch that internally uses Planck to implement it.

mfikes 2016-10-19T15:51:16.000378Z

Here it is for reference:

! /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]))
(-&gt; (core/slurp core/in) reader/read-string (d/pprint {:width 70 :theme (themes/get-theme "light")})

mfikes 2016-10-19T15:54:25.000379Z

FWIW, I’ve also written this just now: https://github.com/mfikes/planck/issues/371