如何在定义rake任务后为其添加说明?

时间:2017-05-10 21:31:28

标签: ruby rake

典型的rake任务定义如下所示:

desc "Set the environment value for the database"
task "environment:set" => [:environment, :load_config] do
  ActiveRecord::InternalMetadata.create_table
  ActiveRecord::InternalMetadata[:environment] = ActiveRecord::Migrator.current_environment
end

但是,如果它没有desc,我想稍后在运行时添加它,在执行任务定义的文件之后。像desc "this is the documentation", task: :taskname这样的东西。这可能吗?

1 个答案:

答案 0 :(得分:0)

是的,你可以在事后添加一个desc,只要它直接在“task”方法之上。

Github仓库的链接已损坏,但如果你看at the source here,你可以看到desc只是附加一个字符串 调用rake -T