tools-deps

Eduardo Lopes 2023-05-25T21:05:59.276759Z

Is there a similar feature in Clojure CLI to Leiningen :injections? I'm using clj -e but I'm wondering if init-opt can be achievable from deps.edn

seancorfield 2023-05-25T21:07:39.253239Z

-e can be put in :main-opts in deps.edn but the specifics depend on exactly what you already have...

seancorfield 2023-05-25T21:07:56.691319Z

Is this just to start a REPL?

seancorfield 2023-05-25T21:10:20.318229Z

(~/clojure/repl)-(!2009)-> cat deps.edn
{:aliases
  {:repl
   {:main-opts ["-e" "(ns foo.bar)" "-r"]}}}

Thu May 25 14:09:54
(~/clojure/repl)-(!2010)-> clj -M:repl
foo.bar=>
point_up::skin-tone-2 does that help?

Eduardo Lopes 2023-05-25T21:13:36.737129Z

Actually is a curiosity based on how githooks works, since we need to manually run git config core.hooksPath dir I can solve this on leiningen projects adding an injection like :injections [(require '[clojure.java.shell :refer [sh]]) (sh ....)] I'm assuming that any lein anything I run will setup githooks for me. So adding this to a specific alias may not solve 100%

Eduardo Lopes 2023-05-25T21:14:33.925819Z

Maybe adding as injections is not the best solution but I always try to "translate" from leiningen to clojure cli what I'm doing

seancorfield 2023-05-25T21:15:58.407319Z

With the CLI, you need an alias for this, or supply it on the command line. But you may be better off writing build.clj for the tasks you want to do since then you can run commands easily and compose things since "it's just code".

seancorfield 2023-05-25T21:16:34.782899Z

I don't really understand your use case tho' -- you only need to run git config once for a given project, yes?

Eduardo Lopes 2023-05-25T21:18:30.245569Z

Yes, was just an idea to avoid manually doing this each time you download and be part of an “invisible” process

Eduardo Lopes 2023-05-25T21:19:07.614979Z

I think using makefile is better for this also, is just a brainstorming

seancorfield 2023-05-25T21:19:16.921759Z

If you're interacting with git, I'd definitely suggest looking at tools.build since it has git functionality in its API. And then just do stuff via clojure -T:build <something> (like lein <something>) and it can do whatever you need...

seancorfield 2023-05-25T21:20:02.861059Z

We have pretty much all our dev/test/CI tooling built around tools.build and build.clj at work -- and I use that approach with most of my OSS projects on GitHub too.

dpsutton 2023-05-25T21:26:13.653529Z

if it’s just once you could do something like clj -X:dev dev/install-git-hooks and code it up yourself

Eduardo Lopes 2023-05-25T22:00:56.021369Z

Yes, both solutions seems better by adding to a makefile. Another use case I remembered was a project using midje, when we executed eastwood and kibit the tests were running, since they load the files. The way to avoid this (don't know if it's the best solution either) was an injection :injections [(require 'clojure.test) (alter-var-root #'clojure.test/*load-tests* (constantly false))] in a linter profile, this could be 100% achievable with an alias on Clojure CLI. The difference is that leiningen allows an injection on the defproject root, which may solve some better use cases than the ones I'm bringing here 😅

Eduardo Lopes 2023-05-25T22:01:51.553009Z

But thanks! I've learned a little more about clj cli with this conversation gratitude