Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more
Show an error and exit
# File rdoc/ri/ri_options.rb, line 117 def OptionList.error(msg) $stderr.puts $stderr.puts msg name = File.basename $PROGRAM_NAME $stderr.puts "\nFor help on options, try '#{name} --help'\n\n" exit 1 end
# File rdoc/ri/ri_options.rb, line 95 def OptionList.options OPTION_LIST.map do |long, short, arg,| option = [] option << long option << short unless short.nil? option << (arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT) option end end
# File rdoc/ri/ri_options.rb, line 107 def OptionList.strip_output(text) text =~ /^\s+/ leading_spaces = $& text.gsub!(/^#{leading_spaces}/, '') $stdout.puts text end
Show usage and exit
# File rdoc/ri/ri_options.rb, line 127 def OptionList.usage(short_form=false) puts puts(RI::VERSION_STRING) puts name = File.basename($0) directories = [ RI::Paths::SYSDIR, RI::Paths::SITEDIR, RI::Paths::HOMEDIR ] if RI::Paths::GEMDIRS then Gem.path.each do |dir| directories << "#{dir}/doc/*/ri" end end directories = directories.join("\n ") OptionList.strip_output(<<-EOT) Usage: #{name} [options] [names...] Display information on Ruby classes, modules, and methods. Give the names of classes or methods to see their documentation. Partial names may be given: if the names match more than one entity, a list will be shown, otherwise details on that entity will be displayed. Nested classes and modules can be specified using the normal Name::Name notation, and instance methods can be distinguished from class methods using "." (or "#") instead of "::". For example: #{name} File #{name} File.new #{name} F.n #{name} zip Note that shell quoting may be required for method names containing punctuation: #{name} 'Array.[]' #{name} compact\\! By default ri searches for documentation in the following directories: #{directories} Specifying the --system, --site, --home, --gems or --doc-dir options will limit ri to searching only the specified directories. EOT if short_form puts "For help on options, type '#{name} -h'" puts "For a list of classes I know about, type '#{name} -c'" else puts "Options:\n\n" OPTION_LIST.each do|long, short, arg, desc| opt = '' opt << (short ? sprintf("%15s", "#{long}, #{short}") : sprintf("%15s", long)) if arg opt << " " << arg end print opt desc = desc.split("\n") if opt.size < 17 print " "*(18-opt.size) puts desc.shift else puts end desc.each do |line| puts(" "*18 + line) end puts end puts "Options may also be passed in the 'RI' environment variable" exit 0 end end