Tablizer: fun experiment with Clojure CLI tools

clj has a different scope than npm, comparing the two is comparing apples and oranges. I also doubt we’ll start seeing a proliferation of command line tools based on Clojure now, there are better languages/environments for that. Still if you want to create and distribute Clojure-based command line tools I can see several options.

  • Do what I did, just let people git clone your repo which contains deps.clj and any scripts
  • Use npm. Why not? It actually contains a mechanism for adding binaries to the shell $PATH, so you can leverage that. Shadow-cljs does this, it really is a brilliant way to make people think that somehow there’s no JVM involved :slight_smile: You can bundle your deps.clj plus a wrapper script that cd's to the right directory and invokes clj . You can even bundle the whole clojure CLI tools if you want to be batteries-included.
  • Publish a jar with a :main namespace to Clojars

This last option is what I would probably do. It works with lein, boot, and clj, and extra benefit: you can also just use it as a library. install instructions are as easy as:

  • add a new alias to ~/.clojure/deps.edn
{
 ,,,
 :aliases
 {:mytool {:extra-deps {mytool {:mvn/version "1.0.0"}}}}}
  • add an alias to ~/.bash_profile
alias mytool='clj -R:mytool -m mytool.main'