1
私はRailsの足場の発電機に似た発電機の作成に取り組んでいます。私はkey:value
引数の配列を受け入れたいと思います。このように:Thor generatorコマンドのkey:value引数の配列を受け入れる方法は?
mycli generate model BlogPost title:string body:text published:datetime
現在、私のコマンドクラスは次のようになります。
require "thor"
module Mycli
module Generators
class Model < Thor::Group
include Thor::Actions
argument :model_name
# argument :model_attributes # TODO: figure out how to get array of attributes
def self.source_root
File.dirname(__FILE__)
end
def generate_model
template('templates/model.tt', "app/models/#{model_name}.rb")
end
def generate_migration
template('templates/migration.tt', "migrations/#{model_name}.rb")
end
end
end
end
私は、属性のリストにアクセスするために行うには何が必要ですか?