class OptParseGen::Renderer
An ERB based renderer.
Public Class Methods
render(options)
click to toggle source
# File lib/optparsegen.rb, line 26 def self.render(options) ERB.new(%Q(require 'optparse' options = Struct.new(<%= options.map { |o| o.symbol_name }.join(', ') %>).new OptionParser.new do |opts| <% for o in options.select { |o| o.name != "help" } %> opts.on(<%= o.opt_args.map { |arg| "'\#{arg}'" }.join(', ') %>) do |v| options.<%= o.underscored_name %> = v end <% end %> opts.on_tail('-h', '--help', 'Shows this usage text.') do puts opts exit end end.parse! ), 0, '>').result(binding) end