Skip to content

Instantly share code, notes, and snippets.

@mtnygard
Forked from athos/deps.edn
Last active April 9, 2024 11:51
Show Gist options
  • Save mtnygard/9b2dd3c88b3309d82210b84f33ee954d to your computer and use it in GitHub Desktop.
Save mtnygard/9b2dd3c88b3309d82210b84f33ee954d to your computer and use it in GitHub Desktop.
Friendly REPL. Run with `clojure -Sdeps '{:deps {hello-clojure {:git/url "https://gist.github.com/mtnygard/9b2dd3c88b3309d82210b84f33ee954d" :sha "774314af2d28261af4a52ac270136d5ba21ff046"}}}' -m frenpl`
{:paths ["." "src" "test"]
:deps {expound {:mvn/version "0.8.4"}
clansi {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.24.0"}
refactor-nrepl {:mvn/version "2.5.0"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}}
(ns frenpl
"The user-friendly REPL"
(:require clansi
[clojure.java.io :as io]
[expound.alpha :as expound]
[clojure.spec.alpha :as s]
[nrepl.server :as nrepl-server]
[cider.nrepl :refer (cider-nrepl-handler)]
[refactor-nrepl.middleware :as refactor]
[rebel-readline.main]))
(def styles
{\b :bg-blue
\g :bg-green
\w :bg-white})
(defn colorize-line [line]
(->> line
(map #(clansi/style " " (get styles % :bg-default)))
(apply str)))
(defn -main [& args]
(with-open [r (io/reader (io/resource "logo.dat"))]
(run! #(println (colorize-line %)) (line-seq r)))
(set! s/*explain-out* (expound/custom-printer {:print-specs? false :show-valid-values? true}))
(spit ".nrepl-port" "7888\n")
(nrepl-server/start-server :port 7888 :handler (refactor/wrap-refactor cider-nrepl-handler))
(println "\n\nNREPL server started on port 7888\n\n")
(apply rebel-readline.main/-main args))
-----------wwwwwwwwww-----------
---------wwwwwbbbbwwwww---------
-------wwwbbbbbbbbbbbwwww-------
------wwbbbbbbbbbbbbbbbwww------
-----wwbbbbbbbbbbbbbbbbbbww-----
----wwbbbbbbbbbbbbbbbbbbbbww----
---wwwwwwwwbbbbbbbbbbbbbbbbww---
--wwwwwwwwwwwwwwwwwbbbbbbbbbww--
--wwwwgggwwwwwbbbbwwwbbbbbbbww--
-wwwwggggwwgwwbbbbbbwwbbbbbbbww-
-wwwgggggwwggwwbbbbbbwwbbbbbbww-
wwwgggggwwgggwwbbbbbbbwwbbbbbbw-
wwgggggwwgggggwwbbbbbbbwbbbbbbww
wwgggggwwgggggwwbbbbbbbwwbbbbbww
wggggggwgggggggwbbbbbbbwwbbbbbww
wggggggwgggggggwbbbbbbbbwbbbbbww
wggggggwggggggwwwbbbbbbbwbbbbbww
wggggggwgggggwwgwbbbbbbwwbbbbbww
wwgggggwwggggwggwwbbbbbwwbbbbbww
wwggggggwgggwwggwwbbbbbwbbbbbbw-
-wggggggwwggwggggwwbbbwwbbbbbww-
-wgggggggwwgwggggwwbbwwbbbbbwww-
-wwgggggggwwwgggggwwwwbbbbwwww--
--wwgggggggwwwwggwwwwwwwwwwwww--
--wwgggggggggwwwwwwgggwwwwggw---
---wwggggggggggggggggggggggww---
----wwggggggggggggggggggggww----
-----wwggggggggggggggggggww-----
------wwwggggggggggggggwww------
--------wwwggggggggggwww--------
----------wwwwwwwwwwww----------
-------------wwwwww-------------
@sgerrand
Copy link

sgerrand commented Apr 9, 2024

Thanks for creating this gist! FYI that running this command locally emits a warning under Clojure v1.11.1.1429:

DEPRECATED: Libs must be qualified, change hello-clojure => hello-clojure/hello-clojure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment