| Class | RI::Options |
| In: |
ri/ri_options.rb
|
| Parent: | Object |
| doc_dir | [R] | the directory we search for original documentation |
| formatter | [R] | the formatting we apply to the output |
| list_classes | [R] | should we just display a class list and exit |
| list_names | [R] | should we display a list of all names |
| use_stdout | [RW] | No not use a pager. Writable, because ri sets it if it can‘t find a pager |
| width | [R] | The width of the output line |
# File ri/ri_options.rb, line 178
178: def initialize
179: @use_stdout = !STDOUT.tty?
180: @width = 72
181: @formatter = RI::TextFormatter.for("plain")
182: @list_classes = false
183: @list_names = false
184: end
Parse command line options.
# File ri/ri_options.rb, line 189
189: def parse(args)
190:
191: old_argv = ARGV.dup
192: # if ENV["RI"]
193: # ARGV.replace(ENV["RI"].split.concat(ARGV))
194: # end
195:
196: ARGV.replace(args)
197:
198: begin
199:
200: go = GetoptLong.new(*OptionList.options)
201: go.quiet = true
202:
203: go.each do |opt, arg|
204: case opt
205: when "--help" then OptionList.usage
206: when "--version" then show_version
207: when "--list-names" then @list_names = true
208: when "--no-pager" then @use_stdout = true
209: when "--classes" then @list_classes = true
210: when "--doc-dir"
211: if File.directory?(arg)
212: @doc_dir = arg
213: else
214: $stderr.puts "Invalid directory: #{arg}"
215: exit 1
216: end
217:
218: when "--format"
219: @formatter = RI::TextFormatter.for(arg)
220: unless @formatter
221: $stderr.print "Invalid formatter (should be one of "
222: $stderr.puts RI::TextFormatter.list + ")"
223: exit 1
224: end
225: when "--width"
226: begin
227: @width = Integer(arg)
228: rescue
229: $stderr.puts "Invalid width: '#{arg}'"
230: exit 1
231: end
232: end
233: end
234:
235: rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
236: OptionList.error(error.message)
237:
238: end
239: end
Return the doc_dir as an array, or nil if no overriding doc dir was given
# File ri/ri_options.rb, line 242
242: def paths
243: defined?(@doc_dir) ? [ @doc_dir ] : nil
244: end