我想知道是否有可能從commande行將選項傳遞給任務,而不需要自己的Rakefile選項。如何將選項傳遞給Rake任務?
這是我的任務:
task :task do
args = ARGV.drop(1)
system("ruby test/batch_of_test.rb #{args.join(' ')}")
args.each { |arg| task arg.to_sym do ; end }
end
這裏是我想成爲功能命令:
rake task --name test_first_one
我要的結果是一樣的:
ruby test/batch_of_test.rb --name test_first_one
對於此代碼,我收到此錯誤:
invalid option: --name
如何將--name(或其他選項)傳遞給我的任務?
的可能的複製[?我如何通過命令行參數rake任務(http://stackoverflow.com/questions/825748/how- do-i-pass-command-line-arguments-to-rake-task) – Robin
不,我至少讀了兩遍。我的問題涉及到傳遞選項而不是完全的參數......(帶「 - 」或「 - 」)。 –