-
-
Notifications
You must be signed in to change notification settings - Fork 290
/
pprint.clj
40 lines (37 loc) · 1.44 KB
/
pprint.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(ns clj-kondo.tools.pprint
(:require
[clj-kondo.core :as clj-kondo]
[clojure.pprint :as p]))
(defn- private-fixed-arity [_x _y _z])
(defmacro macro-varargs-arity [_x & _xs])
(defn -main [& [format & paths]]
(if (empty? paths)
(println "usage: <(edn | table)> <(true | false)> <path>+")
(let [format (case format "edn" :edn "table" :table)
analysis (:analysis (clj-kondo/run!
{:lint paths :config
{:analysis true}}))
{:keys [:namespace-definitions
:namespace-usages
:var-definitions
:var-usages]} analysis]
(case format
:table
(do
(print ":namespace-definitions")
(p/print-table [:filename :row :col :name :doc :author :added :deprecated :no-doc]
namespace-definitions)
(println)
(print ":namespace-usages")
(p/print-table [:filename :row :col :from :to]
namespace-usages)
(println)
(print ":var-definitions")
(p/print-table [:filename :row :col :ns :name :doc :fixed-arities :varargs-min-arity :private :macro :added :deprecated]
var-definitions)
(println)
(print ":var-usages")
(p/print-table var-usages))
:edn
(p/pprint analysis)
(println "use table or edn as first argument")))))