The Deps and CLI Guide is actually pretty clear.
Basically, the formula is:
- Create a top level ns (e.g.
foo
). - In that ns, create a standard main function. Note that it will only terminate if you explicitly call
(System/exit)
yourself. - Invoke the application as
clj -m name-of-ns
, e.g.clj -m foo
.
To use these elsewhere:
- Commit to git.
- Add an alias to your deps.edn file. The alias can be whatever you want. Declare your dependency with the
:deps
key and specify the actual invocations with:main-opts
. - Invoke the alias as
clj -A:alias
.
You can now invoke as:
clj -m ls
clj -m list-instances