Skip to content

Commit

Permalink
Lil task that prints var name and its metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Dec 1, 2021
1 parent 98052ae commit 3ad1b4a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,23 @@
map-fn (if (:all options) identity (fn [m] (dissoc m :subject :graph)))
result (map map-fn
(filter filter-fn (json/parse-string rdf-data true)))]
(pprint/pprint result)))}}}
(pprint/pprint result)))}

var-meta
{:doc "Prints var metadata for source-paths. Defaults to src/ for source-paths"
:usage "[& SOURCE-PATHS]"
:requires ([babashka.pods :as pods])
:task (let [paths (or (seq *command-line-args*) ["src"])]
(pods/load-pod "clj-kondo") ;; Need at least "2021.10.19"
(require '[pod.borkdude.clj-kondo :as clj-kondo])

(let [{{:keys [var-definitions]} :analysis}
((requiring-resolve 'clj-kondo/run!)
{:lint paths
:config {:output {:analysis {:var-definitions {:meta true}}}}})
matches (keep (fn [m]
(when (:meta m)
{:var (str (:ns m) "/" (:name m))
:meta (:meta m)}))
var-definitions)]
(prn matches)))}}}

1 comment on commit 3ad1b4a

@latacora-gabriel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semperos Hey! Hope you're doing well. As a metadata fan you may like this script. I realize you prefer your metadata in-situ but perhaps it's useful for non-metazoaed repositories. Example use at clj-kondo/clj-kondo#1280 (comment)

Please sign in to comment.