parse(args)
public
Parse command line options.
Show source
def parse(args)
old_argv = ARGV.dup
ARGV.replace(args)
begin
go = GetoptLong.new(*OptionList.options)
go.quiet = true
go.each do |opt, arg|
case opt
when "--help" then OptionList.usage
when "--version" then show_version
when "--list-names" then @list_names = true
when "--no-pager" then @use_stdout = true
when "--classes" then @list_classes = true
when "--system" then @use_system = true
when "--site" then @use_site = true
when "--home" then @use_home = true
when "--gems" then @use_gems = true
when "--doc-dir"
if File.directory?(arg)
@doc_dirs << arg
else
$stderr.puts "Invalid directory: #{arg}"
exit 1
end
when "--format"
@formatter = RI::TextFormatter.for(arg)
unless @formatter
$stderr.print "Invalid formatter (should be one of "
$stderr.puts RI::TextFormatter.list + ")"
exit 1
end
when "--width"
begin
@width = Integer(arg)
rescue
$stderr.puts "Invalid width: '#{arg}'"
exit 1
end
end
end
rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
OptionList.error(error.message)
end
end