tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
Jakub Holý 2020-11-01T17:54:31.210200Z

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" (https://clojure.org/guides/deps_and_cli#_using_a_main does not mention how to hardcode the function. I have also tried https://clojure.org/reference/deps_and_cli#_running_a_main_or_script and add :main-opts ["-m" "clj-tumblr-summarizer.main/-main"])

✅ 1
practicalli-john 2020-11-01T18:04:58.210500Z

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 https://github.com/practicalli/clojure-deps-edn

vlaaad 2020-11-01T18:05:08.210800Z

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

practicalli-john 2020-11-01T18:06:01.211100Z

snap 🙂

practicalli-john 2020-11-01T18:07:27.211300Z

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

borkdude 2020-11-01T19:00:52.211700Z

That's not true though:

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

👍 1
seancorfield 2020-11-01T19:28:05.211900Z

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.

👍 1
seancorfield 2020-11-01T19:28:50.212100Z

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.

seancorfield 2020-11-01T19:31:34.212300Z

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

: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)

seancorfield 2020-11-01T19:32:09.212500Z

See https://clojure.org/reference/deps_and_cli#_operation (just after the link you already posted).

Jakub Holý 2020-11-01T19:39:10.212800Z

Thanks a lot!