We already have swank, lein repl, cake, nrepl, detour, clj, reply, … and now we 
have the combo "cljsh & repls".

"repls" is a lein plugin, which is essentially leiningen's native "lein repl" 
task with some default config options for the (not-)printing of eval results 
and repl-prompt. It gives you a persistent repl-server that uses the basic 
repl-protocol: clj-code as text for the reader thru stdin, and evaluated 
results and printed side-effects thru stdout. Install it with "lein plugin 
install lein-repls 1.6.0", and run the repl-server in your project directory 
with "lein repls", and just leave it running...

"cljsh" is a "clojure shell" bash-script that uses "socat" under the covers to 
make the repl-server's stdin and stdout appear local to cljsh. It allows for a 
relatively simple sending of clj-statements and clj-files to the persistent 
repl-server. cljsh is also very lightweight, like cake/nailgun, with a 
negligible startup time, which makes the evaluation of much of your clj-code 
almost instant. You run cljsh like a normal shell script, like bash or sed, and 
pass clj-code statements and files as command line directives or piped-in thru 
stdin. That code is sent to the persistent repl-server, and the printed results 
and output are available on cljsh's stdout. Almost sounds too simple… Download 
the cljsh script from github: 
"https://raw.github.com/franks42/lein-repls/master/bin/cljsh.sh"; and put it 
somewhere in your path. An example command line invocation looks like:

  $ cljsh -c '(println "hello")'  
  hello  
  $  

or a more contrived example:

  $ cat third.clj | cljsh -c '(println "first")' -i second.clj - fourth.clj 
-myargs

The cljsh-test.sh script shows most of the supported features: 
"https://github.com/franks42/lein-repls/blob/master/bin/cljsh-test.sh";.

cljsh also supports an interactive repl-mode with history and completion 
support thru rlwrap - pretty much like the other repls, except that this one 
starts-up instantly, and you can have multiple, concurrent repl-sessions 
working with the same persistent repl-server. (not sure why you would do that… 
but you can/could… ;-)). The completion words can easily be updated with cljsh 
to reflect the evaluation context, but remember that rlwrap is a poor-man's 
completion solution… even though it works pretty well most of the time.

Possible usage scenarios.
Easy to write cljsh-scripts that can be used to select code in any text editor 
or any app and send for evaluation. Select any symbol in any app/browser and 
lookup the doc. Use growl notification to show you the doc or the stack trace 
or eval result. Write your clj-based unix filter. Browse the filesystem with fs 
by changing the repl-prompt to reflect your cwd. Write your clj-based macosx 
automation service. Please let me know if you come up with any others…

Even though it all seems to work pretty well on my macosx… your mileage may 
vary on the other unixes, and it most probably won't work on windows… maybe 
cygwin(?). Please let me know of any compatibilty issues.

Next step: extend it to support clojurescript. (…driving a browser UI thru 
unix-style filters and scripts from the command line…)

Please take a look at the README at: "https://github.com/franks42/lein-repls"; 
for details.
Any feedback is very much appreciated.

Enjoy, FrankS.



 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to