On Wed, Feb 1, 2012 at 3:39 AM, Frank Siebenlist <frank.siebenl...@gmail.com> wrote: > 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.
Just tried it. This is what I have in Ubuntu petr@host:~$ lein repls Exception in thread "main" java.lang.Exception: Couldn't connect (NO_SOURCE_FILE:0) at clojure.lang.Compiler.eval(Compiler.java:5440) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$script_opt.invoke(main.clj:270) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:457) at clojure.lang.Var.invoke(Var.java:377) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.Exception: Couldn't connect at leiningen.repls$poll_repl_connection.invoke(repls.clj:129) at leiningen.repls$repls.invoke(repls.clj:184) at leiningen.repls$repls.invoke(repls.clj:155) at clojure.lang.Var.invoke(Var.java:361) at clojure.lang.AFn.applyToHelper(AFn.java:159) at clojure.lang.Var.applyTo(Var.java:482) at clojure.core$apply.invoke(core.clj:540) at leiningen.core$apply_task.invoke(core.clj:260) at leiningen.core$_main.doInvoke(core.clj:325) at clojure.lang.RestFn.invoke(RestFn.java:410) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.core$apply.invoke(core.clj:542) at leiningen.core$_main.invoke(core.clj:328) at user$eval42.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) ... 11 more And runnung cljsh.sh gives petr@host:~$ cljsh.sh -c '(println "hello")' /home/petr/bin/cljsh.sh: 20: Syntax error: "(" unexpected -- Petr Gladkikh -- 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