Can a rake task know about the other tasks in the invocation chain?
Rake (like make) is able to have many targets/tasks specified on invocation. Is it possible for a rake task to access the 开发者_运维技巧list of tasks the user invoked, in order to do its job?
Scenario:
Consider a Rake-based build tool. A help task would like to know what tasks were also specified in order to print their usage and halt the build process. The benefit of this as opposed to rake-style parameter passing are cleaner syntax (rake help build
instead of rake help task=build
) and chaining (rake help build run_tests
would print usage for both).
Yes, it can, by accessing Rake.application.top_level_tasks
and examining the collection that's returned.
精彩评论