| In: |
StdlibDoc/GenDoc/App.rb
|
| Parent: | Object |
This class implements the application itself. It is run, it parses arguments, and it decides what needs to be done.
Only intended usage: StdlibDoc::GenDoc::App.new.run(ARGV)
# File StdlibDoc/GenDoc/App.rb, line 47 def run(args) puts "Welcome to the GenDoc app!" options = _parse(args) pp options gendoc = StdlibDoc::GenDoc::GenDoc.new(options) case options.operation when :target gendoc.gen_targets when :all_targets gendoc.gen_all_targets when :packaging gendoc.gen_packaging when :all gendoc.gen_all end end
Parse the arguments given for command-line options, and return an Options object.
# File StdlibDoc/GenDoc/App.rb, line 70 def _parse(args) # :doc: options = Options.new do |o| o.config = StdlibDoc::Config.new o.operation = :target o.targets = [] o.force = false end parser = OptionParser.new do |p| p.banner = %{ Usage: ruby stdlib-doc.rb gendoc <command> [options] [target ...] }.trim.tabto(0) p.separator "" p.separator " Commands:" p.on("--all-targets", "Build all targets") do options.operation = :all_targets end p.on("--packaging", "Build index.html, table of contents, etc.") do options.operation = :packaging end p.on("--all", "Build everything (all targets and packaging)") do options.operation = :all end p.on("--check", "Examine Ruby lib directory for unknown targets") do options.operation = :check end p.separator "" p.separator " Options:" p.on("-f", "--force", "Force rebuilding of RDoc output") do options.force = true end p.on("--ruby-base DIR", "Specify Ruby base directory as DIR") do |dir| options.config.ruby_base = dir end p.on("--doc-base DIR", "Specify documentation output base directory as DIR") do |dir| options.config.doc_base = dir end p.separator "" p.separator " Miscellaneous:" p.on("--help", "-h", "Show this message and exit") do _show_usage(p, STDOUT, 0) end p.separator "" p.separator " Examples:" p.separator " ruby stdlib-doc.rb gendoc cgi rexml benchmark # Build these three targets" p.separator " ruby stdlib-doc.rb gendoc --all # Build all targets (most common)" end parser.parse!(args) rescue _show_usage(parser, STDERR, 1) options.targets = args || [] if options.operation == :target and options.targets.empty? _show_usage(parser, STDERR, 1) end options end