Class: SelectRailsLog::CommandLineOptions

Inherits:
Options
  • Object
show all
Defined in:
lib/select_rails_log/command_line_options.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Options

#fetch

Constructor Details

#initializeCommandLineOptions

Returns a new instance of CommandLineOptions.



14
15
16
17
18
19
20
21
# File 'lib/select_rails_log/command_line_options.rb', line 14

def initialize
  super
  @parser = OptionParser.new
  @parser.banner += " [logfiles...]"
  @extensions = {}
  @extension_groups = {}
  setup
end

Class Attribute Details

.initializersObject (readonly)

Returns the value of attribute initializers.



9
10
11
# File 'lib/select_rails_log/command_line_options.rb', line 9

def initializers
  @initializers
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



12
13
14
# File 'lib/select_rails_log/command_line_options.rb', line 12

def parser
  @parser
end

Instance Method Details

#add_option(ext_name, opt_name, *optparse_args, default: nil) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/select_rails_log/command_line_options.rb', line 33

def add_option(ext_name, opt_name, *optparse_args, default: nil)
  self[ext_name][opt_name] = nil

  parser.on(*optparse_args) do |value|
    value = default if value.nil?
    self[ext_name][opt_name] = value
  end
end

#extensions(group) ⇒ Object



42
43
44
# File 'lib/select_rails_log/command_line_options.rb', line 42

def extensions(group)
  @extension_groups[group]
end

#parse!(argv) ⇒ Object



23
24
25
# File 'lib/select_rails_log/command_line_options.rb', line 23

def parse!(argv)
  parser.parse!(argv)
end

#register(ext_name) ⇒ Object



27
28
29
30
31
# File 'lib/select_rails_log/command_line_options.rb', line 27

def register(ext_name)
  return if key?(ext_name)

  self[ext_name] = Options.new
end