Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9947 (closed enhancement: incomplete)

Opened 2 years ago

Last modified 2 years ago

Add task arguments to Capistrano

Reported by: aqsalter Assigned to: minam
Priority: normal Milestone: 2.x
Component: Capistrano Version: edge
Severity: normal Keywords:
Cc:

Description

I'm working on adding task arguments to Capistrano, but I've hit an area where I'm not sure how to continue and felt it was probably best to throw it out to the Capistrano developers before I go any further.

What I would like is if you could pass arguments to Cap like:

cap upload[dir_a,dir_b,dir_c]

I have done some testing and this seems to work fine, in that Cap says it is unable to find task "upload[dir_a,dir_b,dir_c]". So it should be just a matter of parsing the task name at time of execution of the task...

The problem is how do you pass the arguments to Cap?

again what I would like is:

task :upload(args)
  ...
end

but this is clearly not possible...

The other problem is that execution of tasks would have to include args so that tasks could be correctly rolled back.

I don't feel this is impossible to achieve, but would like some guidance before I continue further.

Cheers, -Adam

Change History

01/30/08 06:12:59 changed by minam

Adam, you might want to take a look at how Rake implements task arguments. There might be some ideas there. Arguments are passed to cap via the ARGV array. Look in the Capistrano::CLI::Options module for the nitty gritty.

01/31/08 01:24:43 changed by aqsalter

Ok, Here's how Rake does it (at least specifying args) on the command line:

rake task[args1,args2]

(no spaces between args) or

rake task["args1, args2"]

(spaces between args)

defining the arguments in a task goes like this

task :my_task, :arg1, :arg2, :needs => :init_task do |t, args|
  puts args[:arg1]
  puts args.arg2
end

Should be fairly self explanatory.

Not sure if cap has a :needs option or not at the moment - is this necessary? Cap has before and after tasks anyway.

Now to figure out how to implement it ;)

02/22/08 01:45:04 changed by minam

  • status changed from new to closed.
  • resolution set to incomplete.

I'm going to close this ticket for now, since trac is really not the right place for a discussion on implementation. However, when you have a patch, please feel free to reopen this or create a new ticket. Thanks!