How about this example:

task :run_my_tasks do
   my_task_1
   my_task_2
end

task :getkey do
   set :key, prompt user for key
end

on :before, "getkeys"


In the above example, I want to prompt the user if they execute either
task_1 or task_2 or run_my_tasks, however, if they execute
run_my_tasks it prompts them twice because of the on :before.

Is there any way to *remember* that getkey was already ran once and
skip it for my_task_2 only if that's run through run_my_tasks?

Sorry I haven't been clear... I'm almost finished with our scripts!

I'll be happy to post some of the final recipes to the community.

Thanks again,
Chad






On Aug 15, 2:48 pm, Lee Hambley <[email protected]> wrote:
> Chad,
> You must specify before `what` :
>
> before 'deploy', 'mytasks:getkey'
>
> Does that work?
>
> -- Lee Hambley
>
> Twitter: @leehambley
> Blog:http://lee.hambley.name/
> Working with Rails:http://is.gd/1s5W1
>
> 2009/8/15 Chad Arimura <[email protected]>
>
>
>
>
>
> > Maybe I should try and describe what I'm trying to achieve:
>
> > For all cap commands (eg. cap deploy, cap myns:launch_instance, etc) I
> > want to first prompt the user for a key, and then have access to that
> > key in all subsequent tasks that are called from the cap command.
> > However, I only want to prompt for the key once, not before each task
> > (which is happening if I use an on :before method)
>
> > Does that make sense?
>
> > On Aug 15, 1:04 pm, Lee Hambley <[email protected]> wrote:
> > > Chad,
> > > "only once" = only on one server, or only once, ever?
>
> > > If the former, you can do a few magic things, ask back on the list and
> > > someone (maybe me) will help -- if you mean once, ever you should attach
> > it
> > > to deploy:cold maybe?
>
> > > -- Lee Hambley
>
> > > Twitter: @leehambley
> > > Blog:http://lee.hambley.name/
> > > Working with Rails:http://is.gd/1s5W1
>
> > > 2009/8/15 Chad Arimura <[email protected]>
>
> > > > Hi All,
>
> > > > I'd like to call an on :before task only once before a deployment
> > > > script.  Is there an easy way to tell it to only run once?  Or
> > > > possibly set a variable and then skip over the task if the variable is
> > > > set?
>
> > > > This didn't work:
>
> > > > on :before, "mytasks:run_only_once"
>
> > > > task :run_only_once do
> > > >  if already_ran.nil?
> > > >    ..stuff..
> > > >  else
> > > >    already_ran = "notnil"
> > > >  end
> > > > end
>
> > > > Thanks for any help!
>
> > > > Chad
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.co.uk/group/capistrano?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to