Class: JSLintV8::OptionParser

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/jslint-v8/option_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptionParser

Returns a new instance of OptionParser.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jslint-v8/option_parser.rb', line 8

def initialize
   super

   @options = {}
   @options[:lint_options] = {}

   self.version = JSLintV8::Version::STRING
   self.banner  = "#{self.banner} <filepattern>..."

   Runner::DefaultOptions.keys.each do |option|
      default = Runner::DefaultOptions[option] ? "on" : "off"

      long  = "--[no-]#{option}"
      desc  = "#{Runner::OptionDescriptions[option]} (default=#{default})"

      on(long, desc) do |value|
         options[:lint_options][option] = value
      end
   end

   on("--json", "Return output in JSON format") do |j|
      options[:json] = j
   end

   on("-h", "--help", "Show this message") do
      STDERR.puts self.help
      exit(-1)
   end

   on("-v", "--version", "Show version") do
      STDERR.puts "#{self.program_name} version #{JSLintV8::Version::STRING}"
      exit(-1)
   end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/jslint-v8/option_parser.rb', line 6

def options
  @options
end