class JsDuck::Options::Processor

A facade for all the command line options processing.

Public Class Methods

process(args) click to toggle source

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.

# 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