views:

26

answers:

1

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).

+1  A: 

Yes, it can, by accessing Rake.application.top_level_tasks and examining the collection that's returned.

andrewdotnich