Rake:如何将参数转发给子 Rake 调用?
因此,在我的 rake 命令中,当我执行 --trace 时,它仅在我手动执行的命令上执行,而不会在自定义 rake 执行的 rake 命令上执行。
我的 Rake 命令:
namespace :db do
task :regenesis do
#because of how devestating this command could be, it's going
# to be forced to use the Test Environment
puts "Re-Generating the Database"
Rake::Task["db:drop RAILS_ENV=test --trace"].invoke
Rake::Task["db:create RAILS_ENV=test"].invoke
Rake::Task["db:create RAILS_ENV=test"].invoke
Rake::Task["db:bootstrap RAILS_ENV=test"].invoke
end
end
理想的是不必在其中硬编码 --trace =D
因此,我应该能够执行 rake db:regenesis --trace,并且它应该将跟踪附加到所有这些 rake 命令上。
我该怎么做?
So, in my rake command, when I do --trace, it only does it on the command I manually execute, and none of the rake commands that the custom rake executes.
My Rake command:
namespace :db do
task :regenesis do
#because of how devestating this command could be, it's going
# to be forced to use the Test Environment
puts "Re-Generating the Database"
Rake::Task["db:drop RAILS_ENV=test --trace"].invoke
Rake::Task["db:create RAILS_ENV=test"].invoke
Rake::Task["db:create RAILS_ENV=test"].invoke
Rake::Task["db:bootstrap RAILS_ENV=test"].invoke
end
end
Twould be ideal to not have to hard code the --trace in there =D
So, I should be able to do rake db:regenesis --trace, and it should append trace onto all of those rake commands.
How do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请检查此问题。如果您无法修改任务以添加参数(由于某种原因),那么您可以使用环境变量,例如:
在您的任务中,您必须查找
ENV["extra_option"]
Please check this question. If you cannot modify your tasks to add the parameters ( for some reason ), then you can use environment variables, like:
And in your tasks you'd have to look for
ENV["extra_option"]