Add support for get-in pprinting

This commit is contained in:
Dmitrii Balakhonskii 2016-04-27 14:44:40 +02:00
parent e4d3c1e56c
commit c63301a564
2 changed files with 12 additions and 2 deletions

View file

@ -5,7 +5,10 @@
"Pretty-print a representation of the project map."
[project & keys]
(if (seq keys)
(doseq [k keys]
(pprint/pprint (project (read-string k))))
(doseq [kstr keys]
(let [k (read-string kstr)]
(pprint/pprint (if (sequential? k)
(get-in project k)
(get project k)))))
(pprint/pprint project))
(flush))

View file

@ -0,0 +1,7 @@
(ns leiningen.pprint-test
(:require [clojure.test :refer :all]
[leiningen.pprint :refer :all]))
(deftest can-pprint
(is (= "1\n" (with-out-str (pprint {:foo 1} ":foo"))))
(is (= "1\n" (with-out-str (pprint {:foo {:bar 1}} "[:foo :bar]")))))