This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-15
Channels
- # beginners (26)
- # biff (28)
- # calva (13)
- # clj-commons (4)
- # clj-kondo (3)
- # clojure (45)
- # clojure-austin (17)
- # clojure-europe (8)
- # clojure-finland (1)
- # clojurescript (14)
- # code-reviews (3)
- # emacs (33)
- # helix (4)
- # holy-lambda (7)
- # joyride (5)
- # keechma (1)
- # meander (4)
- # membrane (3)
- # missionary (22)
- # nbb (1)
- # off-topic (1)
- # pathom (4)
- # rdf (24)
- # releases (2)
- # sci (3)
- # shadow-cljs (12)
- # tools-deps (14)
I'm curious how folks run multiple aliases that each have their own :main-opts
. It's my understanding that only the last alias's main opts are run. So what would you do if you want to run something like clj -M:repl:server
where both repl
and server
aliases have opts?
I'm currently just running the aliases individually in a separate terminal but I imagine there might be a more efficient way
haha, I did a search of the channel and it looks like I asked the same question over a year ago. Time flies! It seems the answer is I just can't do what I was attempting but I'll leave the question here in case things have changed or someone can recommend a better workflow
You can write your own function that launches both things and have an alias for that.
Personally, I never start a server from the command-line if I'm developing - I always start everything from the repl
If the built in clojure repl is enough, you can -r
as one of your main opts to also launch the repl.
Thanks folks. I usually connect my editor through a nrepl so not sure the built in one will work. I have wanted to move to a more repl based workflow for starting servers and such so this is a good time to start. That is one of the things that libraries like Component, Integrant, Mount, etc. help with too right?
I'm not talking about the built-in one. I start nREPL from the command-line, connect my editor to that, then start my web server or applications from within the editor, using that REPL connection.
Just to clarify what I'm suggesting.
So I made a dev
alias that loads in a dev/user.clj
file that I setup like so:
(ns user
(:require
[ring-app.core :refer [-main]]))
(defonce server (-main))
(defn start []
(.start server))
(defn stop []
(.stop server))
(defn restart []
(stop)
(start))
(comment
(start)
(stop)
(restart)
,)
where (-main)
starts my jetty server. The thing I can't figure out is how to refactor this such that the server isn't automatically started when invoking clj -M:dev:repl
. What should I do instead of the defonce
?I have an alias that loads dev/user.clj
via an extra path. In the user namespace I have everything in a comment
form, except for the ns
form that defines any requires
So namespaces are loaded, but code that initiates anything is in a comment
The only exceptions to that rule are println statements to show useful information on REPL startup and global logging context for mulog.
Here is what I am using on my current project (it uses integrant, but thats abstracted to the system
namespace so any component system could be used - or none)
https://gist.github.com/practicalli-john/904b5d9ae398aaec2649b50b98a709eb
☝️:skin-tone-2: Yup, that's what I have, essentially. I have a -main
so that I can "run" my dev startup via -M
but I can safely load the ns without it doing anything.