seancorfield/dot-clojure

Can it add an `-Xalias list` option to list out all deps.edn aliases?

stardiviner opened this issue · 5 comments

Hope dot-clojure can add a command-line option to list all configured deps.end aliases. So that users don't need to view the deps.edn to get to know about them.

Is this possible?

There is no built-in facility within the Clojure CLI to list available aliases.

I implemented one code. Don't know whether it is suitable.

{:aliases
 {:alias {:main-opts, ["-e", "(let [edn (slurp (.getPath (clojure.java.io/file (clojure.string/replace-first \"~/.clojure/deps.edn\" \"~\" (System/getProperty \"user.home\")))))] (doseq [key (keys (:aliases (clojure.edn/read-string edn)))] (println key)))"]}}}

That won't work on XDG systems (just FYI) and, yes, I know I have something similar in my :dev/repl alias but, as it says in the README, this is my personal file provided as an example of what's possible.

I think a tool based on tools.deps.alpha would be the best approach since it can list all the aliases available in a given context (there are aliases in the root deps.edn and potentially in a project deps.edn too).

You could post on https://ask.clojure.org asking for a feature like that to be added directly to t.d.a so you could do something like clojure -X:deps aliases

That's good advice. Thanks. I will post there.

If you do, I'll upvote it because I think it would be useful.