Class: JsDuck::Options::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/options/processor.rb

Overview

A facade for all the command line options processing.

Class Method Summary collapse

Class Method Details

.process(args) ⇒ Object

Takes a list of command line options, parses it to an Options::Record object, validates the options, applies it to various singleton classes and returns the Options::Record.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jsduck/options/processor.rb', line 18

def self.process(args)
  # HACK! First establish warnings defaults.
  Logger.configure_defaults

  opts = Options::Parser.new.parse(args)

  # Expand list of input files
  Options::InputFiles.new(opts).expand!

  # Validate the options.
  # Exit program when there's an error.
  if err = opts.validate!
    Array(err).each {|line| Logger.fatal(line) }
    exit(1)
  end

  # Configure various objects with these options
  Logger.configure(opts)
  Util::Parallel.configure(opts)
  TagRegistry.configure(opts)
  Js::ExtPatterns.configure(opts)
  Util::Json.configure(opts)
  Util::IO.configure(opts)

  opts
end