Within a rake task how does one query the description? Something that would give:
desc "Populate DB"
task populate: :environment do
puts task.desc # "Populate DB"
end
Within a rake task how does one query the description? Something that would give:
desc "Populate DB"
task populate: :environment do
puts task.desc # "Populate DB"
end
task
must be defined as a parameter for the task-block.Edit: This solution works with rake 0.8.7. At least rake 0.9.2.2 need an additional
Rake::TaskManager.record_task_metadata = true
(I checked only this two versions).A stand alone ruby-script with adaption:
Reason: in
rake/task_manager.rb
line 30 (rake 0.9.2.2) is a checkThe default
false
is set in line 305.Having a similar problem, that I wanted to show the user a customized help screen. The answer here helped me a lot.
It is very important that
is done before the first definition of tasks.
Then you can do
Details can be found by investigating https://github.com/jimweirich/rake/blob/master/lib/rake/application.rb#L284