Fork me on GitHub
#planck
<
2016-10-19
>
rafaelzlisboa13:10:34

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

curl -H “Accept: application/edn”  | planck

mfikes13:10:19

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

mfikes13:10:05

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

mfikes13:10:32

@rafaelzlisboa

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)}))’
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)

rafaelzlisboa15:10:56

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

mfikes15:10:37

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

rafaelzlisboa15:10:06

makes total sense to me. thanks!

mfikes15:10:53

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

mfikes15:10:16

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

mfikes15:10:25

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