Show an error and exit
# File rdoc/ri/ri_options.rb, line 116 def OptionList.error(msg) $stderr.puts $stderr.puts msg $stderr.puts "\nFor help on options, try 'ri --help'\n\n" exit 1 end
# File rdoc/ri/ri_options.rb, line 94 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 106 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 125 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 ] directories << "#{Gem.path}/doc/*/ri" if RI::Paths::GEMDIRS 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: ri File ri File.new ri F.n ri zip Note that shell quoting may be required for method names containing punctuation: ri 'Array.[]' ri 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 'ri -h'" puts "For a list of classes I know about, type 'ri -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