On Jan 15, 2009, at 11:31 AM, Chouser wrote:
I had a launch script (which I've now lost due to my own clumsiness) that defaulted to a repl if given no file options, and always loaded a .clojurerc.clj file before starting a repl (whether it was by default or specifically asked via -r). This allowed me to load repl-utils and get *print-length* set up before getting a prompt. But if a file was named with [no] -r, it was run with no repl. It used appropriate combinations of clojure.lang.Repl or clojure.lang.Script and file paths to make this happen. As far as I can tell this is impossible with clojure.main, which appears to only allow loading a file *or* starting a repl. Am I missing a method to support this, or should I go back to using Script/Repl?
Given the clj script I posted earlier (which uses clojure.main directly) all of the following are possible. I think one of these covers the case you're asking about. If not, please let me know.
Launch a repl with no command-line-arguments: clj Run a script: clj my-script Run a script with command line args: clj my-script 1 2 3 Load an init file from classpath then run a repl: clj --init @my-init.clj --repl Load an init file from classpath then run a repl with command line args: clj --init @my-init.clj --repl 1 2 3Load an init file from classpath and run a script with command line args:
clj --init @my-init.clj my-script 1 2 3 Load two init files and run a repl with command line args: clj --init @my-init.clj --init my-script --repl 1 2 3I recognize that having this documented at http://clojure.org/repl_and_main will be very helpful to everyone. I'm working on that and I'll upload it before the end of this weekend.
--Steve
smime.p7s
Description: S/MIME cryptographic signature