Skip to content

Commit 62a9936

Browse files
committed
Improve handling of ri's --help and --version options
Explicitly handle ri's --help and --version options instead of relying on OptionParser's default behavior. This makes both options appear in the ri --help text. This also fixes `ri -h' which did not work as expected: instead of displaying the help text, ri started in interactive mode, apparently ignoring the option.
1 parent 5a969a9 commit 62a9936

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/rdoc/ri/driver.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ def self.process_args argv
242242
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
243243
end
244244

245+
opt.separator nil
246+
247+
opt.on("--help", "-h",
248+
"Show help and exit.") do
249+
puts opts
250+
exit
251+
end
252+
253+
opt.separator nil
254+
255+
opt.on("--version", "-v",
256+
"Output version information and exit.") do
257+
puts "#{opts.program_name} #{opts.version}"
258+
exit
259+
end
260+
245261
opt.separator nil
246262
opt.separator "Data source options:"
247263
opt.separator nil

0 commit comments

Comments
 (0)