This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-15
Channels
- # aleph (24)
- # announcements (8)
- # babashka (27)
- # beginners (55)
- # biff (4)
- # calva (32)
- # cider (5)
- # clj-kondo (11)
- # clojure (59)
- # clojure-android (3)
- # clojure-australia (1)
- # clojure-belgium (6)
- # clojure-dev (21)
- # clojure-europe (26)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojurescript (19)
- # css (1)
- # data-science (10)
- # datahike (17)
- # events (3)
- # figwheel-main (4)
- # honeysql (1)
- # hugsql (5)
- # hyperfiddle (1)
- # jobs (1)
- # leiningen (3)
- # lsp (6)
- # malli (5)
- # meander (4)
- # nbb (6)
- # off-topic (87)
- # pathom (19)
- # portal (2)
- # re-frame (4)
- # reitit (6)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (29)
- # sql (8)
- # tools-deps (6)
- # xtdb (7)
Hello all, I have a question on deps Tools, the -T option.
I’ve noticed that args need a key/value pair which does not satisfy my use case. For example clj -Tcljd -main 1 2 3
will generate a Key is missing value: 3
error. Is there a way around this ?
-T
works like -X
and calls a function with a hash map.
You can't call -main
as that expects a sequence of strings.
You would need an "exec" function entrypoint such as:
(defn main-x [{:keys [args]}] (apply -main args))
which you could then invoke as
clojure -Tcljd main-x :args '["1" "2" "3"]'
(you could do (apply -main (map str args))
and then pass :args '[1 2 3]'
on the command-line if you wanted to avoid the quoting).But the usual approach is to have -main
parse its arguments into a hash map and then call an "exec" style function -- parsing string args with something like clojure.tools.cli
(which produces a hash map of arguments).
The Cognitect test-runner is structured like that: https://github.com/cognitect-labs/test-runner
It has an api.clj
entrypoint for direct exec that massages the initial hash map something before invoking the same function that -main
invokes.
Ok, thanks a lot Sean 🙏