method
process_args
v1_9_3_125 -
Show latest stable
- Class:
RDoc::RI::Driver
process_args(argv)public
Parses argv and returns a Hash of options
# File lib/rdoc/ri/driver.rb, line 108
def self.process_args argv
options = default_options
opts = OptionParser.new do |opt|
opt.accept File do |file,|
File.readable?(file) and not File.directory?(file) and file
end
opt.program_name = File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
opt.summary_indent = ' ' * 4
opt.banner = Usage: #{opt.program_name} [options] [names...]Where name can be: Class | Class::method | Class#method | Class.method | methodAll class names may be abbreviated to their minimum unambiguous form. If a nameis ambiguous, all valid options will be listed.A '.' matches either class or instance methods, while #methodmatches only instance and ::method matches only class methods.For example: #{opt.program_name} Fil #{opt.program_name} File #{opt.program_name} File.new #{opt.program_name} zipNote that shell quoting or escaping may be required for method names containingpunctuation: #{opt.program_name} 'Array.[]' #{opt.program_name} compact\\!To see the default directories ri will search, run: #{opt.program_name} --list-doc-dirsSpecifying the --system, --site, --home, --gems or --doc-dir options willlimit ri to searching only the specified directories.Options may also be set in the 'RI' environment variable.
opt.separator nil
opt.separator "Options:"
opt.separator nil
formatters = RDoc::Markup.constants.grep(/^To[A-Z][a-z]+$/).sort
formatters = formatters.sort.map do |formatter|
formatter.to_s.sub('To', '').downcase
end
opt.on("--format=NAME", "-f",
"Uses the selected formatter. The default",
"formatter is bs for paged output and ansi",
"otherwise. Valid formatters are:",
formatters.join(' '), formatters) do |value|
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
end
opt.separator nil
opt.on("--no-pager", "-T",
"Send output directly to stdout,",
"rather than to a pager.") do
options[:use_stdout] = true
end
opt.separator nil
opt.on("--width=WIDTH", "-w", OptionParser::DecimalInteger,
"Set the width of the output.") do |value|
options[:width] = value
end
opt.separator nil
opt.on("--interactive", "-i",
"In interactive mode you can repeatedly",
"look up methods with autocomplete.") do
options[:interactive] = true
end
opt.separator nil
opt.on("--list", "-l",
"List classes ri knows about.") do
options[:list] = true
end
opt.separator nil
opt.on("--[no-]profile",
"Run with the ruby profiler") do |value|
options[:profile] = value
end
opt.separator nil
opt.separator "Data source options:"
opt.separator nil
opt.on("--list-doc-dirs",
"List the directories from which ri will",
"source documentation on stdout and exit.") do
options[:list_doc_dirs] = true
end
opt.separator nil
opt.on("--doc-dir=DIRNAME", "-d", Array,
"List of directories from which to source",
"documentation in addition to the standard",
"directories. May be repeated.") do |value|
value.each do |dir|
unless File.directory? dir then
raise OptionParser::InvalidArgument, "#{dir} is not a directory"
end
options[:extra_doc_dirs] << File.expand_path(dir)
end
end
opt.separator nil
opt.on("--no-standard-docs",
"Do not include documentation from",
"the Ruby standard library, site_lib,",
"installed gems, or ~/.rdoc.",
"Use with --doc-dir") do
options[:use_system] = false
options[:use_site] = false
options[:use_gems] = false
options[:use_home] = false
end
opt.separator nil
opt.on("--[no-]system",
"Include documentation from Ruby's standard",
"library. Defaults to true.") do |value|
options[:use_system] = value
end
opt.separator nil
opt.on("--[no-]site",
"Include documentation from libraries",
"installed in site_lib.",
"Defaults to true.") do |value|
options[:use_site] = value
end
opt.separator nil
opt.on("--[no-]gems",
"Include documentation from RubyGems.",
"Defaults to true.") do |value|
options[:use_gems] = value
end
opt.separator nil
opt.on("--[no-]home",
"Include documentation stored in ~/.rdoc.",
"Defaults to true.") do |value|
options[:use_home] = value
end
opt.separator nil
opt.separator "Debug options:"
opt.separator nil
opt.on("--dump=CACHE", File,
"Dumps data from an ri cache or data file") do |value|
options[:dump_path] = value
end
end
argv = ENV['RI'].to_s.split.concat argv
opts.parse! argv
options[:names] = argv
options[:use_stdout] ||= !$stdout.tty?
options[:use_stdout] ||= options[:interactive]
options[:width] ||= 72
options
rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
puts opts
puts
puts e
exit 1
end Related methods
- Instance methods
- add_also_in
- add_class
- add_from
- add_includes
- add_method_list
- ancestors_of
- class_cache
- class_document
- classes
- classes_and_includes_for
- complete
- display
- display_class
- display_method
- display_name
- display_names
- expand_class
- expand_name
- filter_methods
- find_methods
- formatter
- in_path?
- interactive
- list_known_classes
- list_methods_matching
- load_method
- load_methods_matching
- method_document
- method_type
- name_regexp
- page
- paging?
- parse_name
- run
- setup_pager
- Class methods
- default_options
- dump
- new
- process_args
- run