hm, I can't seem to get clojure -Mxxx --eval to work.
; clojure -Mrebel --eval "(require '[clojure.repl :refer [doc]])"
The following errors occurred while parsing your command:
Unknown option: "--eval"
the help message says this should work ok:
Usage:
Run main clojure [clj-opt*] -M[aliases] [init-opt*] [main-opt] [arg*]
init-opt:
-e, --eval string Eval exprs in string; print non-nil values
what am I doing wrong here?For Rebel Readline I define an alias in my user level Clojure config https://github.com/practicalli/clojure-cli-config/blob/87ff98610531522d43b6fa8fb6fd1b71940e205c/deps.edn#L159
:repl/rebel
{:extra-deps {nrepl/nrepl {:mvn/version "1.5.1"}
cider/cider-nrepl {:mvn/version "0.58.0"}
com.bhauman/rebel-readline {:mvn/version "0.1.5"}}
:main-opts ["--eval" "(apply require clojure.main/repl-requires)"
"--main" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"
"-f" "rebel-readline.main/-main"]}
Then call clojure -M:repl/rebel
The --eval part of the alias definition loads things like add-libs.
As sean mentions, I use the built-in doc key mapping thar Rebel provides.> Try clojure -A:rebel -M -e "(require '[clojure.repl :refer [doc]])" -m rebel-readline.main > I'm not certain that will work -- it kinda depends on what Rebel Readline does unfortunately it did not work:
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
The following errors occurred while parsing your command:
Unknown option: "-e"
Unknown option: "-m"
i ended up just bypassing the shell script altogether and invoking the jar file directly.if it helps, I found that the clojure shell script is running java -classpath /home/jyn/.m2/repository/org/clojure/clojure/1.12.0/clojure-1.12.0.jar clojure.main -m rebel-readline.main --eval ...; if i switch the order of --eval and -m in that invocation, things work ok. but i don't know how to convince the shell script wrapper to do that.
-Mrebel should be -M:rebel BTW. But that means that it will run clojure.main (as you can see), passing -m rebel-readline.main as the "main namespace" argument to clojure.main/-main (the Main-Class). Anything following that is arguments to the main function you are invoking (i.e., rebel-readline.main/-main).
You want --eval (`-e`) to be passed to clojure.main, so you need it before the -m rebel-readline.main argument (which is supplied by your alias :rebel), so you can't do it like that...
This is a limitation of :main-opts in your :aliases.
Try clojure -A:rebel -M -e "(require '[clojure.repl :refer [doc]])" -m rebel-readline.main
I'm not certain that will work -- it kinda depends on what Rebel Readline does -- but I'll also note that Rebel Readline offers it's own way to show docs: ^X ^D which will show the docs for the symbol at the cursor.