Fork me on GitHub
#tools-deps
<
2021-07-25
>
stuartrexking21:07:44

How do I add an additional alias to clj -X:deps tree. The alias dev as extra-deps, but they don’t show up in the tree when I clj -X:deps:dev tree

seancorfield21:07:41

Use -Stree instead of -X:deps tree

seancorfield21:07:39

clojure -Stree -A:dev for example @stuartrexking

thanks3 3
tree-shake 3
borkdude22:07:23

It means -A:foo:bar:baz

borkdude22:07:10

if you do -X:foo:bar:baz for example, the deps from aliases foo and bar are included on the classpath. also those of baz, but you will only eXecute a function from the baz alias.

borkdude22:07:12

The last one wins.

seancorfield22:07:56

Although :exec-fn is "last one wins", :exec-args are merged across all the aliases you specify. That can be a very useful trick to use aliases to modify the behavior of an exec function.

seancorfield22:07:53

So if each of :foo, :bar, and :baz have both :exec-fn and :exec-args, then the function that gets invoked will be :baz's :exec-fn but with a merged hash map of the :exec-args from all three aliases.

seancorfield22:07:02

No. For a brief while you could specify multiple functions tho' but that went away.

borkdude22:07:21

was that only in a pre-release?

borkdude22:07:26

the threading thing?

seancorfield22:07:54

clojure -X:foo:bar:baz my.first/func another/func third/func -- was that only in a prerelease? Dunno. I'm always using one of the latest prereleases so I can't remember.

seancorfield22:07:29

I think it'll come back at some point but there were ambiguities in terms of argument parsing...

borkdude22:07:18

In general when you write :foo:bar:baz it means you invoke :baz (exec, main, tool) but with additional deps from aliases foo and bar

seancorfield22:07:48

The -X behavior with multiple aliases is not documented. The behavior for :main-opts (and thus -A/`-M`) is documented, as it is for :paths and several other things.

seancorfield22:07:17

Search this page https://clojure.org/reference/deps_and_cli for multiple to see the other documented behavior.

seancorfield22:07:15

There's definitely a lot of "assumed knowledge" in the deps.edn/CLI docs, unfortunately. I think partly because it has changed a lot over time and partly because a lot of the early users have always been in this channel providing feedback, even before features got implemented, so some of those discussions just never made it into the docs...

seancorfield22:07:18

Several of the (older) sections on that reference page have bulleted lists with the keys they relate to and a bullet that says "If multiple alias maps with these keys are activated..." but the -X stuff is introduced in a different way near the top of the page and then the argument parsing is described in detail at the bottom of the page, but there's no simple bulleted list of its keys and behavior.

seancorfield22:07:20

(and now that I read it, I see concatentating is misspelled five time on that page)

seancorfield22:07:44

I've never noticed that before and I've read that page so many times...

borkdude22:07:46

perhaps it's a new Clojure word?

seancorfield22:07:57

I think adding a Function execution section to the overall Execution section, between Main execution and Prepare for execution would be a good start. It could list the four keys that affect function execution (`:exec-fn`, :exec-args, :ns-default, and :ns-aliases) and the "If multiple alias maps with these keys are activated..." bullet.

seancorfield22:07:04

I think that's the only example in the docs tho'...

seancorfield22:07:51

Easy to miss, two thirds down that page.

seancorfield22:07:04

Probably, since that would be the first "mention" of multiple aliases assuming someone reads the entire guide first then then entire reference manual...

seancorfield22:07:16

How I start my REPL:

SOCKET_REPL_PORT=5000 clojure -Sforce -M:rebel:reflect:jedi-time:reveal:j14:classes:everything:dev:test:build:runner:dev/repl
👀

👀 3
seancorfield22:07:25

No, aliases can't be amalgams of other aliases (a feature lots of people have requested).

seancorfield22:07:42

Maybe I should write a blog post about my REPL? :thinking_face:

yes 11
seancorfield22:07:44

:everything:dev:test:build:runner all comes from our work project deps.edn and the other aliases from my dot-clojure deps.edn (in the repo on GitHub). Just FYI.

seancorfield22:07:50

Yeah, I've been putting off some chores I should go and do (it's just too hot here).