Fork me on GitHub
Jakub Holý (HolyJak)17:11:31

Hello! I am sorry, I obviously am not good enough in reading docs. What do I need to do to be able to run my project with just clj -X without arguments? I have tried

{:deps {...}
 :exec-fn   clj-tumblr-summarizer.main/-main}
but that complains "No function found on command line or in :exec-fn" ( does not mention how to hardcode the function. I have also tried and add :main-opts ["-m" "clj-tumblr-summarizer.main/-main"])


You need to define an alias to use with the -X flag. My understanding is the -X flag should be used with an alias, as I havent seen any examples of using :exec-fn as a top level key. From the error you are getting, this seems to be a correct... There are plenty of examples of :exec-fn , :exec-args and :ns-default in the practicalli/clojure-deps-edn


I think exec-fn has to be in alias, and -X requires alias


You can specify :exec-fn on the command line I believe, if you really dont want an alias Edit: hmm, I am not sure that is right now. You can specify a function, but still has to be with an alias. Edit: as borkdues says below, if its a fully qualified function on the class path, then the command line is enough - need to add some good examples to the book so I dont forget


That's not true though:

$ clj -X clojure.core/prn :foo 1 :bar 2
{:foo 1, :bar 2}

👍 3

You can't run just clj -X on its own. You either have to provide an alias or you have to specify the function to call on the command-line.

👍 3

Just like :main-opts can't be at the top level in deps.edn, :exec-fn, :exec-args, :ns-default, etc all need to be under an alias.


There are only a few keys valid at the top level @U0522TWDA

:deps - map of lib (symbol) to coordinate
:paths - vector of paths
:aliases - map of alias name to alias data
provider-specific keys for configuring dependency sources
(that last one is stuff like :mvn/repos)