Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Nicer formatting for `lein deps :tree` #492

Merged
merged 1 commit into from Apr 2, 2012
Jump to file or symbol
Failed to load files and symbols.
+11 −2
Split
View
@@ -3,6 +3,16 @@
(:require [leiningen.core.classpath :as classpath]
[clojure.pprint :as pp]))
+;;; TODO: Get rid of this recursion
+(defn- print-tree
+ ([tree level increment]
+ (doseq [[n c] tree]
+ (println (str (apply str (repeat level \space))) n)
+ (when c
+ (print-tree c (+ level increment) increment))))
+ ([tree increment]
+ (print-tree tree 0 increment)))
+
(defn deps
"Download all dependencies.
@@ -11,6 +21,5 @@ You should never need to invoke this manually."
(deps project nil))
([project tree]
(if (= tree ":tree")
- (do (pp/pprint (classpath/dependency-hierarchy :dependencies project))
- (flush))
+ (print-tree (classpath/dependency-hierarchy :dependencies project) 4)
(classpath/resolve-dependencies :dependencies project))))