[Rake-devel] Suggestion: allow passing of extra command-line argsto the task

Bennett, Patrick Patrick.Bennett at inin.com
Mon Jun 14 08:47:40 EDT 2004


Wouldn't it be better to define a syntax where arbitrary 'named'
arguments can be specified? (like make)
Something like:
rake clean html html_file=foo.html -dtest -dFOO
Rake would then expose all defined parameters to rakefiles as a hash.  
Any xxx=yyy command line argument would be assumbed to be a name/value
parameter.  -d could be used as a shortcut way of saying xxxx=true, or
to simply make it a bit clear (-d html_file=foo.html).
Ie:
  desc "Generate HTML document."
  task :html do
    require 'generate'
    generate_document( Rake::ARGS['html_file'] || DEFAULT_INPUT_FILE)
  end

I'm definitely against the multiple file, multiple arguments per file
approach.  I think it's better to just change rake to allow rakefile
chaining.  I added a method called 'subdirs' for rakefiles so that a
rakefile can look like:
task xxxxx
task yyy

subdirs('unit_tests','examples')

After rake finishes the current file, it then walks through a queue of
subdirectories (that is modified by subdirs).  It clears out all task
objects, then looks for a rakefile in the next directory off the queue.

> -----Original Message-----
> From: rake-devel-bounces at rubyforge.org [mailto:rake-devel-
> bounces at rubyforge.org] On Behalf Of Gavin Sinclair
> Sent: Monday, June 14, 2004 7:24 AM
> To: Rake Development and Discussion
> Subject: Re: [Rake-devel] Suggestion: allow passing of extra
command-line
> argsto the task
> 
> On Monday, June 14, 2004, 9:20:03 PM, Martin wrote:
> 
> >> What I'm getting at is this.  If rake did support the CL syntax you
> >> describe, I would still do this instead for clarity:
> >>
> >>   rake clean
> >>   rake html -f other.txt
> >>   rake test -f test.in
> >>   rake make
> >>   rake make-install
> >>
> >> But looking at the above, I think the addition of -f does serve to
> >> visually distinguish between the target and its arguments.
> >>
> >> Conclusion: I like the -f idea, but see no need to introduce the
\;.
> 
> > True, for much the same reason that people tend to have one ruby
> statement per
> > line, even though the language allows semicolons. But by the same
token,
> if you
> > don't want to use them, you don't need to. I just like the \; for
> generality
> > (i.e. you can have multiple targets, and each target can have
multiple
> > arguments). If nothing else, letting them all be on one line lets
you
> uparrow
> > and repeat the command.
> 
> I simply cannot argue against such logic.  Brilliant :)
> 
> I guess the question now is: is there a slightly less ugly syntax,
> pitched at the same level of generality?
> 
> Actually, the main question is: what does Jim think of all this?
> 
> Gavin
> 
> _______________________________________________
> Rake-devel mailing list
> Rake-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rake-devel





More information about the Rake-devel mailing list