So, you want the name of the task that was invoked first, at the top of the call chain? That's pretty much how you'd do it--there's no shortcut for that in cap, since I've never needed one, and no one else has ever submitted a patch. :)

However, you can shorten it a big by dropping "self" -- since, "self" is always the implied recipient of the message. Furthermore, I find ".first" to be more readable than "[0]". Thus:

  task_call_frames.first.task.fully_qualified_name

Still a mouthful, but I find it reads better.

- Jamis

On Feb 1, 2008, at 3:09 PM, Peter Boling wrote:


I am using:

self.task_call_frames[0].task.fully_qualified_name

within my tasks whenever I want to print the task I am running.  I
have this task to do that:

namespace :show do
 desc "Show some internal Cap-Fu: What's mah NAYM?!? "
 task :me do
   set :command, self.task_call_frames[0].task.fully_qualified_name
   puts "echo 'Running #{command} task'"
 end
end

Which will output something like:
Running deploy:cold task

Is there a cleaner method I could call, other than
"self.task_call_frames[0].task.fully_qualified_name".  Wow that's a
mouthful.

It took me way too long to dig that one out of capistrano and I just
feel like there must have been a better way!

Thanks,
Peter
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to