Method: Gonzui::CommandLineSearcher#initialize

Defined in:
lib/gonzui/cmdapp/search.rb

#initialize(config, options) ⇒ CommandLineSearcher

Returns a new instance of CommandLineSearcher.



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
42
43
44
45
46
# File 'lib/gonzui/cmdapp/search.rb', line 14

def initialize(config, options)
  @config = config
  @dbm = DBM.open(@config, true)
  @out = (options['out'] or STDOUT)
  @nlines  = options['line-number']

  @show_method = if options['context']
                   :show_context_lines 
                 elsif options['count']
                    :show_count
                 else
                    :show_line
                 end

  @package_name = options['package']

  @ncontexts = options['context'].to_i

  @search_method = :find_all
  @search_method = :find_all_by_prefix if options['prefix']
  @search_method = :find_all_by_regexp if options['regexp']

  @use_regexp  = options['regexp']
  @use_color   = options['color']
  @no_filename = options['no-filename']

  @target_type = :all
  if options['type']
    type = options['type'].intern
    eprintf("unknown type: #{type}") unless LangScan::Type.include?(type)
    @target_type = type
  end
end