Fork me on GitHub
#beginners
<
2023-03-05
>
sheluchin18:03:34

Does there happen to be any tool that converts clj + flags invocations to deps.edn entries?

seancorfield18:03:04

Can you explain what you mean by that?

sheluchin18:03:11

When I have something like this:

clj \
-Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"}}}' \
-A:reveal \
-M -m nrepl.cmdline --middleware '[vlaaad.reveal.nrepl/middleware]'
my assumption is that with the exception of the alias -A definition, all of these options have some equivalent form that can be used in a deps.edn configuration. I'm wondering if there is some helper tool that helps with this cli<->deps.edn translation.

seancorfield18:03:57

-M with an alias would include :main-opts which is where you'd put ["-m" "nrepl.cmdline" "--middleware" "[vlaad.reveal.nrepl/middleware]"] - is that what you're asking?

seancorfield18:03:54

This can't really be automated by a tool since the aliases you'd need to add and how they are combined needs to be decided by a human.

practicalli-johnny00:03:27

There is a large collection of aliases you can use / copy / be inspired by at https://github.com/practicalli/clojure-deps-edn (the readme also has a link to Sean's aliases too)

gratitude-thank-you 2
Δημήτριος Φκιαράς19:03:20

Hello all! I have this map, with n elements.

(def m {:01 12341241234, :02 5489348, :03 45799 ....etc})
I also have n functions. How can I map my functions their corresponding elements?
(fn1 (:01 m))
(fn2 (:02 m))
.
.
.
(fnX (:X m))
To be more specific, is there a way to store functions in a map?

kennytilton19:03:08

"is there a way to store functions in a map?" Sure, functions are just data, like the numbers in your map m. I like the name, btw. 🙂 Did you try it and it not go well?

❤️ 2
Michael W19:03:22

You can store a function in a map, but not a macro.

user=> (def m {:map map})
#'user/m
user=> ((:map m) identity [1 2 3])
(1 2 3)
user=> (def m {:and and})
Syntax error compiling at (REPL:1:1).
Can't take value of a macro: #'clojure.core/and

❤️ 2
Δημήτριος Φκιαράς19:03:34

Thanks. @U0PUGPSFR I did, but failed for some reason. Now it seems to work. Maybe I was too tired!