Fork me on GitHub
#tools-deps
<
2021-04-03
>
mokr15:04:23

Hi, is there any plans to allow some sugar (short names / shortcuts) that would allow one to hide the sometimes long, not so sexy, commands behind a short name? Like Leiningen does with “aliases” (!= deps aliases)? So that e.g. clj graph could execute clj -X:graph graph :deps '"mydeps.edn"' :trace true :output '"trace" I know tools deps is not intended to replace Leiningen, but it seem to have fragmented the already small Clojure(script) community and intended or not, my impression is that it’s used as a replacement as is, with no other tool wrapping it. I do not mean to be rude and I’m very grateful for all the hard work that Cognitect and others puts into the tech I benefit from. I’m just a bit concerned in regards to how it looks to outsiders and newcomers and that you now need to remember, wrap in a script or copy paste long commands to get things done. Sure you can still use lein, but enough people seem to have transitioned that it’s pretty much mandatory to know both. PS: If I missed something obvious here, then please enlighten me, nothing would be more welcome.

vlaaad15:04:31

Sounds like aliases with :exec-fn and :exec-args

andy.fingerhut15:04:57

I believe it is semi-common to create short bash scripts and/or Makefile kind of things for this, too.

Alex Miller (Clojure team)15:04:10

the best place to file requests is at https://ask.clojure.org (and this is not something that has an existing question specifically for it already afaik) - asking there lets this accumulate votes, which we factor into prioritization

Alex Miller (Clojure team)15:04:31

as @U47G49KHQ says, you can get part of the way there by creating an alias with :exec-fn and :exec-args keys and then invoking the alias. for this example, you'd create an alias like:

:trace {:exec-fn graph 
        :exec-args {:deps "mydeps.edn"
                    :trace true
                    :output "trace"}}
and then execute this in combination with the graph tool like:
clj -X:trace:graph

Alex Miller (Clojure team)15:04:48

or you could fold the :graph alias stuff into that same alias to get down to just clj -X:trace

Alex Miller (Clojure team)15:04:10

there is also some additional work coming soon around tool installation

🤤 15
mokr16:04:40

Thanks, I knew this was close to a feature request, but I wanted to see the reaction to it 🙂 For some reason I keep forgetting that http://ask.clojure.org exists. If that’s the desired channel, then I will consider writing up something around this. Clojure itself and many of the libraries are very elegant and concise and I have the same hopes for the tooling.

borkdude17:04:01

@U1S4F3M4M I am making something like "npm scripts" for babashka: https://github.com/babashka/babashka/discussions/765#discussioncomment-564820 Feel free to give feedback

borkdude17:04:59

It's already possibly today to "hide" this behind a function and call it like bb -m tasks/my-clojure-invocation

borkdude17:04:52

Also made a short video about it: https://youtu.be/_zr1dicJs-E

mokr17:04:12

@U04V15CAJ Thanks, I think I have had a look at babashka previously, but after a quick read now I see that I should have another look as it might actually fit well in my toolbox. That said, I think my initial question/request should be solved preferably in tools-deps itself to keep things simple. Especially for beginners that will soon enough have to navigate the library landscape in search of pieces that fit together.

borkdude17:04:45

Right. It would be useful if deps.edn had something like lein aliases. I wished this existed so I'm implementing it for bb. But I want to support something broader than lein aliases (more something in between npm run and make) and I don't expect deps.edn will support this use case. There is always the startup of the JVM too.

borkdude17:04:56

But only having "shortcuts" for specific clojure invocations would already be useful.

practicalli-john06:04:39

I just use my shell history, I never have to type in a full command more than once. I have zsh (presto) with fish shell completion. A lot simpler than any other approach.

mpenet17:04:23

Just (Justfile) is also a good companion to deps.edn, it's quite easy to replicate most of lein with it +deps.edn

mpenet17:04:49

There are many runners like this that can be used for now