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("Usage:\n\n\#{name} [options] [names...]\n\nDisplay information on Ruby classes, modules, and methods.\nGive the names of classes or methods to see their documentation.\nPartial names may be given: if the names match more than\none entity, a list will be shown, otherwise details on\nthat entity will be displayed.\n\nNested classes and modules can be specified using the normal\nName::Name notation, and instance methods can be distinguished\nfrom class methods using \".\" (or \"#\") instead of \"::\".\n\nFor example:\n\n\#{name} File\n\#{name} File.new\n\#{name} F.n\n\#{name} zip\n\nNote that shell quoting may be required for method names\ncontaining punctuation:\n\n\#{name} 'Array.[]'\n\#{name} compact\\\\!\n\nBy default ri searches for documentation in the following\ndirectories:\n\n\#{directories}\n\nSpecifying the --system, --site, --home, --gems or --doc-dir\noptions will limit ri to searching only the specified\ndirectories.\n\n")
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