class EotbGenerator < Rails::Generator::Base def add_options!(opt) opt.on('-k', '--api-key=key', String, "Your Beholder API key") {|v| options[:api_key] = v} end def manifest record do |m| ensure_parameter_was_set m.template "initializer.rb", "config/initializers/eotb.rb", :assigns => {:api_key => api_key_exp} end end def api_key_exp "#{options[:api_key]}" end def ensure_parameter_was_set if !options[:api_key] puts "Must pass --api-key or create config/initializers/eotb.rb" exit end end end