On 3/8/09 7:46 PM, S. Robert James wrote:
> Is there a standard Capistrano idiom for passing in, and parsing, user
> defined parameters from the command line? I know vars can be set using
> -S. But I'd like more: supporting boolean switches, or switches with
> a default val. If I was writing my own script, I'd use OptionParser or
> the like - what's the preferred Capistrano way to do this?
The 'cap' utility doesn't have any way for you to extend the supported
set of command-line switches. However, you could write your own utility
that wraps Capistrano and has it's own set of switches. You could
probably just subclass Capistrano::CLI, implement the command-line
parsing stuff, and call that from your own wrapper.
> Along similar lines, is there a standard idiom for a task to take a
> parameter, or return a result? I could hack this with a global
> variable, but I'd like to find a preferred way.
Nope. What you could probably do is implement the task as a vanilla Ruby
method, and then invoke the method wherever needed:
def my_stuff(param1, param2, ...)
run "..."
return some_value
end
task :my_task do
puts my_stuff(a, b, ...)
end
- Jamis
> >
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---