| 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 220
220: def initialize
221: @use_stdout = !STDOUT.tty?
222: @width = 72
223: @formatter = RI::TextFormatter.for("plain")
224: @list_classes = false
225: @list_names = false
226:
227: # By default all paths are used. If any of these are true, only those
228: # directories are used.
229: @use_system = false
230: @use_site = false
231: @use_home = false
232: @use_gems = false
233: @doc_dirs = []
234: end
Parse command line options.
# File ri/ri_options.rb, line 238
238: def parse(args)
239:
240: old_argv = ARGV.dup
241:
242: ARGV.replace(args)
243:
244: begin
245:
246: go = GetoptLong.new(*OptionList.options)
247: go.quiet = true
248:
249: go.each do |opt, arg|
250: case opt
251: when "--help" then OptionList.usage
252: when "--version" then show_version
253: when "--list-names" then @list_names = true
254: when "--no-pager" then @use_stdout = true
255: when "--classes" then @list_classes = true
256:
257: when "--system" then @use_system = true
258: when "--site" then @use_site = true
259: when "--home" then @use_home = true
260: when "--gems" then @use_gems = true
261:
262: when "--doc-dir"
263: if File.directory?(arg)
264: @doc_dirs << arg
265: else
266: $stderr.puts "Invalid directory: #{arg}"
267: exit 1
268: end
269:
270: when "--format"
271: @formatter = RI::TextFormatter.for(arg)
272: unless @formatter
273: $stderr.print "Invalid formatter (should be one of "
274: $stderr.puts RI::TextFormatter.list + ")"
275: exit 1
276: end
277: when "--width"
278: begin
279: @width = Integer(arg)
280: rescue
281: $stderr.puts "Invalid width: '#{arg}'"
282: exit 1
283: end
284: end
285: end
286:
287: rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
288: OptionList.error(error.message)
289:
290: end
291: end
Return the selected documentation directories.
# File ri/ri_options.rb, line 295
295: def path
296: RI::Paths.path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs)
297: end
# File ri/ri_options.rb, line 299
299: def raw_path
300: RI::Paths.raw_path(@use_system, @use_site, @use_home, @use_gems,
301: *@doc_dirs)
302: end