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
Yes. But, because we are not on paid Slack, we can’t scroll back to see the solution 😞
(It involved using Planck’s pretty printer. That solution could be reconstructed.)
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)@mfikes how would you feel about having a --pretty-print
option for this?
@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.
makes total sense to me. thanks!
@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.
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")})
FWIW, I’ve also written this just now: https://github.com/mfikes/planck/issues/371