ninjudd / cake

A tasty build tool for Clojure.
clojure-cake.org
Eclipse Public License 1.0
171 stars 12 forks source link

Command line arguments not being passed to script #98

Closed lynaghk closed 13 years ago

lynaghk commented 13 years ago

Putting

(println *command-line-args*)

in a file and running it with

cake run <filename> "my argument"

prints nil. Am I missing something?

davidsantiago commented 13 years ago

Well, it is official cake policy to make breaking changes and then not update the docs. That variable was changed to just args recently. I'll talk to ninjudd later about some changes to the docs.

lynaghk commented 13 years ago

The variable *args* is not defined, and I get a stacktrace. I'm using cake 0.6.0 via the rubygem.

davidsantiago commented 13 years ago

Hm, you got me. I had this same problem last weekend and ninjudd said he'd changed it to args, but I get the same as you.

davidsantiago commented 13 years ago

Duh. You want cake/args, not just args.

davidsantiago commented 13 years ago

Just kidding! Pretty sure this still doesn't work. Even better, cake is still defining command-line-args in eval.clj and useful.clj, but not in the shared bindings in project.clj. I don't actually know what all that means, so I'm gonna have to talk to ninjudd about what exactly he is intending to do here with respect to this issue.

lynaghk commented 13 years ago

It looks like I can get to the command line arguments like so;

(:run cake/*opts*)

but it's not as nice to say as *command-line-args* =)

davidsantiago commented 13 years ago

Ah, well, if you want the parsed options, you want to be using opts. What used to be command-line-args and should someday hopefully be args is the unparsed version of the command line, which can be useful sometimes.

ninjudd commented 13 years ago

this works for me on cake 0.6.1:

fallout:~ master$ cake run foo.clj "foo bar"
(foo bar)

*args* is the raw args passed to cake. *command-line-args* is bound for convenience to be all *args* after the name of the script. this change was made at the request of Raynes, and i think it makes sense.

ninjudd commented 13 years ago

i'm closing this. please reopen if this still doesn't work as i've described after updating to the latest cake version.

also, let me know the exact name and path of your script and the exact command being used to invoke it.

thanks

davidsantiago commented 13 years ago

ninjudd, if I do 'cake repl -a 1 -b 2', what should args be? Because for me, it is nil.

\- David
ninjudd commented 13 years ago

args are not passed to the project jvm by bake. they are mostly for use in cake tasks, but you can pass them manually using bake bindings

lynaghk commented 13 years ago

Upgrading to 0.6.1 fixed the issue. Thanks guys!