How do I execute Rake tasks with arguments multiple times?

前端 未结 4 1249
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 04:39

It\'s not possible to invoke the same rake task from within a loop more than once. But, I want to be able to call rake first and loop through an array

4条回答
  •  悲哀的现实
    2021-02-19 04:52

    The execute function asks for a Rake::TaskArguments as a parameter, this is why it only accepts one argument.

    You could use

    stuff_args = {:match => "HELLO", :freq => '100' }
    Rake::Task["stuff:sample"].execute(Rake::TaskArguments.new(stuff_args.keys, stuff_args.values))
    

    However there is another difference between invoke and execute, execute doesn't run the :prerequisite_task when invoke does this first, so invoke and reenable or execute doesn't have exactly the same meaning.

提交回复
热议问题