rake 任务可以知道调用链中的其他任务吗?
Rake(如 make)能够在调用时指定许多目标/任务。 rake 任务是否可以访问用户调用的任务列表以完成其工作?
场景:
考虑一个基于 Rake 的构建工具。帮助任务想知道还指定了哪些任务,以便打印它们的用法并停止构建过程。与 rake 式参数传递相比,这样做的好处是更清晰的语法(rake help build
而不是 rake help task=build
)和链接(rake help build run_tests
将打印两者的使用情况)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,可以通过访问 Rake.application.top_level_tasks 并检查返回的集合来实现。
Yes, it can, by accessing
Rake.application.top_level_tasks
and examining the collection that's returned.