summaryrefslogtreecommitdiff
path: root/lib/rdoc/ri/driver.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-16 12:31:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-16 12:31:29 +0000
commit9bc2e3280a5ef48395b47fa6155ad8cdc303e606 (patch)
tree06a109f4139ecb1408073b01c4d053ce57491a15 /lib/rdoc/ri/driver.rb
parent75d694e535282cd5e2b0ab4ac3743042e0d03e05 (diff)
* lib/rdoc/ri/driver.rb (RDoc::RI::Driver.setup_options)
(RDoc::RI::Driver.fixup_options): split from process_args. libraries should not parse ARGV inside, since it's a task of applications, not libraries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/driver.rb')
-rw-r--r--lib/rdoc/ri/driver.rb29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 7ae73a490e..f3fd9539e3 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -97,10 +97,23 @@ class RDoc::RI::Driver
##
# Parses +argv+ and returns a Hash of options
- def self.process_args argv
+ def self.process_args argv = []
options = default_options
+ opts = OptionParser.new
+ setup_options(opts, options)
- opts = OptionParser.new do |opt|
+ argv = ENV['RI'].to_s.split.concat argv
+ opts.parse!(argv)
+
+ fixup_options(options, argv)
+
+ rescue OptionParser::ParseError => e
+ puts opts, nil, e
+ abort
+ end
+
+ def self.setup_options(opt, options)
+ begin
opt.accept File do |file,|
File.readable?(file) and not File.directory?(file) and file
end
@@ -274,11 +287,9 @@ Options may also be set in the 'RI' environment variable.
options[:dump_path] = value
end
end
+ end
- argv = ENV['RI'].to_s.split.concat argv
-
- opts.parse! argv
-
+ def self.fixup_options(options, argv)
options[:names] = argv
options[:use_stdout] ||= !$stdout.tty?
@@ -286,12 +297,6 @@ Options may also be set in the 'RI' environment variable.
options[:width] ||= 72
options
-
- rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
- puts opts
- puts
- puts e
- exit 1
end
##