Re: detecting running as script

2018-06-13 Thread Patrik Sundberg
et Atwood > > > -- > *From:* clo...@googlegroups.com > on behalf of Patrik Sundberg > > *Sent:* Tuesday, June 12, 2018 6:13:39 AM > *To:* Clojure > *Subject:* Re: detecting running as script > > I thought this was the go-to libr

RE: detecting running as script

2018-06-12 Thread Sean Corfield
M To: Clojure Subject: Re: detecting running as script I thought this was the go-to library for command line parsing: https://github.com/clojure/tools.cli On Wednesday, January 14, 2009 at 7:11:23 PM UTC, Grunde Løvoll wrote: Thanks! I'll have a look at clojure.contrib.command-line. I don't

Re: detecting running as script

2018-06-12 Thread Patrik Sundberg
I thought this was the go-to library for command line parsing: https://github.com/clojure/tools.cli On Wednesday, January 14, 2009 at 7:11:23 PM UTC, Grunde Løvoll wrote: > > Thanks! > > I'll have a look at clojure.contrib.command-line. I don't need > anything super-powerfull, just something th

Re: detecting running as script

2009-01-14 Thread Grunde Løvoll
Thanks! I'll have a look at clojure.contrib.command-line. I don't need anything super-powerfull, just something that make it easy to define and parse command line arguments in the "normal manner". Sorry about my previous double post :( Grunde On Wed, Jan 14, 2009 at 6:00 PM, Chouser wrote: >

Re: detecting running as script

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 5:58 AM, Grunde wrote: > > Now, it these some elegant way to parse and use the passed command > line arguments in my program? Is there any lib like Ruby/Pythons > optparse to assist parsing of command line arguments? There is clojure.contrib.command-line I don't know if

Re: detecting running as script

2009-01-14 Thread Grunde
Hi folks, I'm almost there. My small script: -- #! /usr/bin/env clj (defn somefunc [& args] (println "somefunc!" args)) (defn main [& args] (somefunc args)) ; Only run the application automatically if run as a script, ; not if loaded in a REPL with load-file. (when *command-line-args*

Re: detecting running as script

2009-01-14 Thread Grunde
Hi all, I managed to make this work by first making a clj script as instructed here: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started (thanks, great stuff!) But there is still one small thing: Is there an elegant way to "unwrap" the passed command line arguments? And is there any

Re: detecting running as script

2009-01-04 Thread Mark Volkmann
On Sun, Jan 4, 2009 at 3:57 AM, Timothy Pratley wrote: > >> I suspect that *command-line-arguments* would have "myapp.clj" as the >> 0th element in the >> clj myapp.clj >> Can't test right now though sorry. > > I tested this and it does work for me. If it does not work for you is > most likely in

Re: detecting running as script

2009-01-04 Thread Meikel Brandmeyer
Hi, Am 04.01.2009 um 11:15 schrieb Timothy Pratley: I can't seem to get this approach working: http://clojure.org/compilation seems to imply that this approach can only be taken using :gen-class and pre-compiling before calling in this way (which makes sense as my.app is not a class yet). Ye

Re: detecting running as script

2009-01-04 Thread Timothy Pratley
Hi Meikel, On Jan 3, 9:03 pm, Meikel Brandmeyer wrote: > java -cp my.app I can't seem to get this approach working: I created a directory "my" and a file "app.clj" containing: (ns my.app) (defn somefunc []) (println "somefunc!" args)) (defn main [& args] (somefunc)) C:\java>java -cp .;"c:

Re: detecting running as script

2009-01-04 Thread Timothy Pratley
> I suspect that *command-line-arguments* would have "myapp.clj" as the > 0th element in the > clj myapp.clj > Can't test right now though sorry. I tested this and it does work for me. If it does not work for you is most likely in your clj script or bat file. I noticed on the wiki the incorrect a

Re: detecting running as script

2009-01-03 Thread Kyle Hargraves
On Sat, Jan 3, 2009 at 12:40 PM, Mark Volkmann wrote: > Sounds good. I can't find the function that returns the current > namespace though. Do you remember what it is? You can get the current namespace from *ns*. k --~--~-~--~~~---~--~~ You received this message

Re: detecting running as script

2009-01-03 Thread Mark Volkmann
On Sat, Jan 3, 2009 at 12:40 PM, Mark Volkmann wrote: > On Fri, Jan 2, 2009 at 11:12 PM, Timothy Pratley > wrote: >> >> Ah, another left field idea: >> if you test the namespace you will find running from REPL the >> namespace will be user >> running from the command will be clojure.core >> I'm

Re: detecting running as script

2009-01-03 Thread .Bill Smith
It's in *ns* isn't it? Bill On Jan 3, 12:40 pm, "Mark Volkmann" wrote: > On Fri, Jan 2, 2009 at 11:12 PM, Timothy Pratley > > wrote: > > > Ah, another left field idea: > > if you test the namespace you will find running from REPL the > > namespace will be user > > running from the command will

Re: detecting running as script

2009-01-03 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 11:12 PM, Timothy Pratley wrote: > > Ah, another left field idea: > if you test the namespace you will find running from REPL the > namespace will be user > running from the command will be clojure.core > I'm certain that will work as I've tested it in the past. > Bit of a

Re: detecting running as script

2009-01-03 Thread Meikel Brandmeyer
Hi, Am 03.01.2009 um 10:48 schrieb Meikel Brandmeyer: Then you can run the script via: java -cp clojure.main my.app Geez. Too early. You don't need the clojure.main. Just: java -cp my.app Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature

Re: detecting running as script

2009-01-03 Thread Meikel Brandmeyer
Hi, Am 02.01.2009 um 17:34 schrieb Mark Volkmann: For example, this should run the application: clj myapp.clj and this should not: clj user=> (load-file "myapp.clj") You should probably pack everything in a namespace with a main function. (ns my.app) ... (defn main [& args] ...) Th

Re: detecting running as script

2009-01-02 Thread Timothy Pratley
Ah, another left field idea: if you test the namespace you will find running from REPL the namespace will be user running from the command will be clojure.core I'm certain that will work as I've tested it in the past. Bit of a hack, but should do the job. --~--~-~--~~~-

Re: detecting running as script

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:20 PM, Timothy Pratley wrote: > > I suspect that *command-line-arguments* would have "myapp.clj" as the > 0th element in the > clj myapp.clj > Can't test right now though sorry. Good idea! Unfortunately it seems that *command-line-args* is nil regardless of whether I loa

Re: detecting running as script

2009-01-02 Thread Timothy Pratley
I suspect that *command-line-arguments* would have "myapp.clj" as the 0th element in the clj myapp.clj Can't test right now though sorry. On Jan 3, 3:34 am, "Mark Volkmann" wrote: > I have a file of Clojure code that I'd like to experiment with in the > REPL. I use (load file-path) to do that a

detecting running as script

2009-01-02 Thread Mark Volkmann
I have a file of Clojure code that I'd like to experiment with in the REPL. I use (load file-path) to do that and then I can try out the functions it defines. At the bottom of the file it calls the functions required to run my application. Is there a way I can write the code so it only runs my app