@seancorfield Is this where we can ask more questions about the video? I've been trying to explore reveal more too so want to follow along with you.
I'm looking at your dot-clojure repo. So I think what's happening is that in you called the :reveal and :dev aliases at the command line.
The :dev alias actually calls out to this dev.clj file which is where all those other reveal options are coming in from. Is that correct?
So to recreate I would create that dev.clj file and throw it next to my deps.edn file?
Probably easier to follow-up either in #tools-deps or via DM but I guess some of this deserves a broader audience...
The dot-clojure repo has a whole bunch of (opinionated) tooling that works together. The dev.clj
file lives in that repo -- i.e., it goes into your .clojure
folder with the (user) deps.edn
which is assumed to contain all the various aliases I regularly use.
:dev
(and now, preferred, :dev/repl
) is an alias that uses :main-opts
to load the dev.clj
script. :reveal
pulls in Reveal and would run it as well, if it were the last alias on the command-line that contained :main-opts
.
To explain that: when you use multiple aliases, their bodies are combined. Mostly they are merged: either a merge of hash maps or a conj of vector contents (`:jvm-opts`) but with :main-opts
it is "last one wins" so only one alias's :main-opts
end up being used.
clj -M:reveal
would start Reveal as the main REPL. clojure -M:rebel
would start Rebel Readline as the main REPL. clj -M:reveal:rebel
will start Rebel Readline but also make Reveal available as a dependency -- because the :main-opts
for :rebel
"wins" by being the last alias.
clojure -M:reveal:rebel:dev/repl
uses the :main-opts
from :dev/repl
as the last alias to have any main opts, so Reveal and Rebel Readline are on the classpath but their -main
functions are not called. The code in dev.clj
runs, looks at what is available via the classpath, and decides which REPL to start up and how to combine the various utilities.
Does that help @chase-lambert?
Mostly! Still wrapping my head around the last alias wins. Is it only in the case of a conflict that it wins because otherwise why use more than one alias.
Oh wait, so only the :main-opts
part pertains to this last one wins.
(one important thing to note is that my :dev
& :dev/repl
aliases will not work on an XDG system because they assume $HOME/.clojure
-- on an XDG system that's most likely to be $HOME/config/clojure
as I recall)
Yep, $HOME/.config/clojure
So your :add-libs
alias has a :main-opts
section and you still use that even though it's not the last alias you call
Several aliases have :main-opts
but those options are not used if a later :main-opts
is present. The aliases still bring in the specified dependencies.
ahh, ok, so you are using everything in the :add-libs
alias except for the :main-opts
With :add-libs
it's just a bit of "magic" to ensure a DCL (DynamicClassLoader) context for any REPL that is started -- but my dev.clj
also contains that code.
Yeah, I'm trying to parse your dev.clj to see if I can yank it wholesale or if it's going to conflict because I'm using cider nrepl vs your socket approach. hahaha
So basically whatever alias that will have the call to this dev.clj
file has to come last right. My apologies if I'm being super dense about this.
The issue I'm working around with that DCL stuff is that a Socket REPL does not use a DCL context (and neither did Cognitect's REBL). Now that I have dev.clj
, any Socket REPL started by it will have a DCL. But I left it in :add-libs
(and :rebl
) so that I can start a more barebones REPL and still have the DCL context that add-libs
(the function) needs.
Yes, clojure -M:lots:of:aliases:and:then:load-dev.clj
Cool, I will try to pilfer what I can. I use your's and practicalli's. That install-reveal-extras
function is a bit intimidating but I think I want it. Haha.
I kind of wish it was just an option to throw in to the reveal main opts. "corfield-reveal-extras" or whatever
And so you aren't getting any of the :main-opts
from :test
either? Hahaha, this seems to be tripping me up. I'm assuming the main opts just aren't that important.
:runner
is the alias I use to run tests. :test
just brings in some useful stuff.
;; testing and debugging tools (this would normally be overridden
;; by a :test alias in the project deps.edn file -- but it's a
;; useful default):
:test {:extra-paths ["test" "src/test/clojure"]
:extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
:test
has no :main-opts
got it! Awesome. The more I use these tools the more I like them but it definitely takes some tweaking
It's like a set of LEGO bricks!
Well put.