Skip to content

Instantly share code, notes, and snippets.

@drbrain
Forked from zzak/mygen.rb
Last active December 15, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drbrain/5259624 to your computer and use it in GitHub Desktop.
Save drbrain/5259624 to your computer and use it in GitHub Desktop.
require 'rdoc'
class RDoc::Options
attr_accessor :you
attr_accessor :me
end
class MyGen
RDoc::RDoc.add_generator self
attr_reader :options
attr_reader :store
def self.setup_options(options)
options.you = "you"
options.me = "me"
opt = options.option_parser
opt.separator nil
opt.separator "MyGen generator options:"
opt.separator nil
opt.on("--you", "-y", "Set your name") do |value|
options.you = value
end
opt.separator nil
opt.on("--me", "-m", "Set my name") do |value|
options.me = value
end
opt.separator nil
puts options.me
puts options.you
end
def initialize(store, options)
@store = store
@options = options
end
end
#options = RDoc::Options.new
#options.setup_generator 'mygen'
#ARGV.push('--format=mygen') if ARGV.grep(/\A(-f|--fmt|--format|-r|-R|--ri|--ri-site)\b/).empty?
RDoc::RDoc.new.document ARGV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment