Skip to content

Commit 3122256

Browse files
committed
switch to -m invocation
Signed-off-by: Sean Corfield <sean@corfield.org>
1 parent 6817e84 commit 3122256

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _Since it is my personal file, it may make assumptions about my own environment.
1414

1515
With that caveat out of the way, here is some basic documentation about my tools and aliases (there are additional examples in the comments in the `deps.edn` file itself). _Note: I have recently cleaned this file up and removed a lot of aliases I no longer use!_
1616

17-
TL;DR: add the following dependency and then start a REPL with `clj -M:dev/repl` (optionally with other aliases to bring in more tooling):
17+
TL;DR: add the following dependency and then start a REPL with `clj -M:dev/repl` (optionally with other aliases before it to bring in more tooling):
1818

1919
```clojure
2020
:aliases
@@ -23,8 +23,12 @@ TL;DR: add the following dependency and then start a REPL with `clj -M:dev/repl`
2323
{io.github.seancorfield/dot-clojure
2424
{:git/tag "v1.1.3"
2525
:git/sha "2fce829"}}
26-
:main-opts ["-e" "((requiring-resolve 'org.corfield.dev.repl/start-repl))"]}}
26+
:main-opts ["-m" "org.corfield.dev.repl"]}}
2727
```
28+
There is also a `bin/repl` bash script that runs `clojure -M:1.12:portal:test:cider-nrepl:rebel:dev/repl`
29+
to start an nREPL server with CIDER middleware, and then a Rebel Readline
30+
interactive REPL, with Portal available (and `clojure.tools.logging`, if
31+
present, patched to `tap>` all log messages for Portal).
2832

2933
## Basic Tools
3034

@@ -126,7 +130,7 @@ To work with the Polylith command-line tool:
126130
127131
## The `:dev/repl` Alias
128132

129-
The `:dev/repl` alias calls `org.corfield.dev.repl/start-repl` in the [`repl.clj` file](https://github.com/seancorfield/dot-clojure/blob/develop/src/org/corfield/dev/repl.clj) from this repo. That does a number of things (see the `start-repl` docstring for more details):
133+
The `:dev/repl` alias calls `org.corfield.dev.repl/-main` in the [`repl.clj` file](https://github.com/seancorfield/dot-clojure/blob/develop/src/org/corfield/dev/repl.clj) from this repo. That does a number of things (see the `-main` docstring for more details):
130134

131135
* Optionally, starts a Socket REPL server (with the port selected via an environment variable, a JVM property, or a dot-file created on a previous run).
132136
* If both Portal and `org.clojure/tools.logging` are on the classpath, it patch `tools.logging` to also `tap>` every log message in a format that Portal understands and can display (usually with the ability to go to the file/line listed in the log entry); call `(dev/toggle-logging!)` to turn this `tap>`'ing on and off.
@@ -142,6 +146,8 @@ _Note 1: since the `repl.clj` code uses `requiring-resolve`, it requires at leas
142146

143147
_Note 2: if the Portal middleware is added to nREPL/CIDER, all evaluated results will be `tap>`'d (if the Portal UI is open and listening); my [VS Code/Calva setup](https://github.com/seancorfield/vscode-calva-setup) has additional configuration for working with Portal when the middleware is enabled!_
144148

149+
_Note 3: as of v1.1.3, adds `user/uptime` so you can easily see how long your REPL has been running, in a human-readable format._
150+
145151
## Use with Figwheel
146152

147153
If you are doing ClojureScript development with Figwheel (`figwheel-main`) then you can do something like:

deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
:extra-deps {io.github.seancorfield/dot-clojure
6565
{:git/tag "v1.1.3"
6666
:git/sha "2fce829"}}
67-
:main-opts ["-e" "((requiring-resolve 'org.corfield.dev.repl/start-repl))"]}
67+
:main-opts ["-m" "org.corfield.dev.repl"]}
6868
;; - in case you need precompiled code on your classpath:
6969
:classes {:extra-paths ["classes"]}
7070
;; - start a Socket REPL on port 50505 (not needed if you use the :dev/repl alias):

src/org/corfield/dev/repl.clj

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; copyright (c) 2018-2024 sean corfield, all rights reserved
22

33
(ns org.corfield.dev.repl
4-
"Invoke org.corfield.dev.repl/start-repl to start a REPL based on
4+
"Invoke org.corfield.dev.repl/-main to start a REPL based on
55
what tooling you have available on your classpath."
66
(:require [clojure.repl :refer [demunge]]
77
[clojure.string :as str]))
@@ -10,12 +10,6 @@
1010
(throw (ex-info ":dev/repl and repl.clj require at least Clojure 1.10"
1111
*clojure-version*)))
1212

13-
(defn up-since
14-
"Return the date this REPL (Java process) was started."
15-
[]
16-
(java.util.Date. (- (.getTime (java.util.Date.))
17-
(.getUptime (java.lang.management.ManagementFactory/getRuntimeMXBean)))))
18-
1913
(defn- socket-repl-port
2014
"Return truthy if it looks like a Socket REPL Server is wanted,
2115
else return nil. The truthy value is the port number to use.
@@ -33,7 +27,7 @@
3327
(Long/parseLong s-port)
3428
(catch Throwable _)))))
3529

36-
(defn- start-repl
30+
(defn -main
3731
"If Jedi Time is on the classpath, require it (so that Java Time
3832
objects will support datafy/nav).
3933
@@ -52,7 +46,7 @@
5246
* if Figwheel Main is on the classpath then start that, else
5347
* if Rebel Readline is on the classpath then start that, else
5448
* start a plain ol' Clojure REPL."
55-
[]
49+
[& args]
5650
;; jedi-time?
5751
(try
5852
(require 'jedi-time.core)

0 commit comments

Comments
 (0)