Fork me on GitHub
#clojure-dev
<
2024-03-06
>
vlaaad15:03:47

Wouldn’t it be cool if I could do clj test , and it could look at :test alias, notice that it has :main vec, and execute the equivalent of clj -M:test ? And similarly for :exec-fn args, it could do -X

thheller15:03:26

whats bad about just running clj -M:test or clj -X:test directly?

vlaaad16:03:27

It's completely unrememberable

7
upvote 3
vlaaad16:03:08

If you have more than say 5 repos, using any of them requires opening and reading deps.edn file

🤝 1
jpmonettas16:03:48

I think that would get confusing pretty quick, if you look at the ClojureScript compiler for example there are a bunch of aliases related to testing different aspects of it, like :compiler.test , :runtime.test or :selfhost.test etc, which is pretty common in many systems, where something like clj test wouldn't be well defined. I'm not saying there aren't better ways, but imho those shorter commands are always at odds with power

Noah Bogart16:03:05

The -M:alias form would still exist for alternative test runs, but I think having a standard "test entrypoint" function would do a lot of good for discoverability and general usage

1
upvote 2
jpmonettas17:03:48

I agree, but then I would prefer something like aliases in shells, so they can be inspected. Like clj test internally expanding to clj -M:test or whatever, so when in doubt you can dump the "aliases" table and quickly figure out what is going on. I prefer that to something by convention, like "clj test will look at the :test alias and if it has a :main vec ...". A concept like that will enable short commands for a bunch of things without adding any complexity beyond support for aliases expansion and knowing there are aliases you can list. Although one problem unfortunately is the aliases word is already taken, which will make the concept confusing

vemv18:03:38

Maybe stating the obvious, but I really like how I can type make test in a pretty wide variety of projects and have the tests run, whether it's a deps.edn, Lein or e.g. Python project - each of those with its own intricacies beyond the basic command syntax. First time (and that was a long time ago), Makefiles seemed to me the most unnecessarily arcane tech in existence, but nowadays they practically only bring joy (and speed, in form of caching).

💯 1
vemv18:03:45

> Wouldn’t it be cool if I could do clj test , and it could look at :test alias, notice that it has :main vec, and execute the equivalent of clj -M:test ? What if there are :test-cljs, :test-integration, etc aliases? Running only :test could lead to running only a subset of tests (easily meaning false negatives in CI)

jpmonettas18:03:19

I've also been using Makefiles for a while and they work, but I guess most people use them as aliases for clj commands, so having support for that in the clj command could get rid of most uses of Makefiles, which are probably bizarre for people new to Clojure

1
vemv18:03:37

Yeah that's fair, I recall some bitter HN comment claiming that the "only" way to make clj palatable is through Makefiles (implying they're a terrible thing)

Noah Bogart18:03:20

Adding support for aliases that are combinations of other aliases (like -M:dev:test:runner) would solve some of this as well

💡 1
Noah Bogart18:03:48

Unless there's a mechanism for running multiple mains in a row, combining aliases won't work like in leiningen, but it's at least shorter than it is right now

leifericf09:03:45

I’m always wrapping the Clojure CLI in shell aliases, a Makefile, or Babashka because the Clojure CLI interface is weird and unintuitive compared to all other command line tools I know. I need to look up the docs every time I need to do something with the Clojure CLI, even though I've done it many times before 😅 Some more intuitive “built-in aliases” for common tasks would be appreciated, indeed.

cjohansen09:03:39

I agree that adding some shortcuts for conventional tasks is a good idea. Sure, lots of projects would not have all their testing needs covered by the suggested clj test but a whole lot of projects would be well served by it. And since it's an alias it doesn't come at the cost of anything, and you can still define it to be meaningful for your project.

upvote 2
cjohansen10:03:00

I love that tools deps has designed for simple, but I think there's a lot of room for adding some easy convenience on top of it

upvote 2
vlaaad11:03:11

I think a lot of people misunderstand what I'm talking about. Let me provide another example. Wouldn't it be cool if I could type clj foo, and it looked up the :foo alias, and executed appropriate -M or -X command depending on the contents of the :foo alias?

💡 2
💯 3
👍 4
upvote 1
1
🌈 1
Noah Bogart14:03:03

Ooooh i see, that makes more sense