Class: I18nFlow::CLI::SearchCommand

Inherits:
CommandBase show all
Defined in:
lib/i18n_flow/cli/search_command.rb,
lib/i18n_flow/cli/search_command/default_renderer.rb,
lib/i18n_flow/cli/search_command/oneline_renderer.rb

Defined Under Namespace

Classes: DefaultRenderer, OnelineRenderer

Constant Summary collapse

DEFAULT_FORMAT =
'default'

Instance Method Summary collapse

Methods inherited from CommandBase

#color_enabled?, #exit_with_message, #initialize

Constructor Details

This class inherits a constructor from I18nFlow::CLI::CommandBase

Instance Method Details

#include_all?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/i18n_flow/cli/search_command.rb', line 38

def include_all?
  !!(options['all'] || options['a'])
end

#invoke!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/i18n_flow/cli/search_command.rb', line 13

def invoke!
  unless pattern
    exit_with_message(1, 'usage: i18n_flow search PATTERN')
  end

  search.search!

  case output_format
  when 'default'
    puts DefaultRenderer.new(search.results, color: color_enabled?).render
  when 'oneline'
    puts OnelineRenderer.new(search.results, color: color_enabled?).render
  else
    exit_with_message(1, 'Unsupported format: %s' % [output_format])
  end
end

#output_formatObject



34
35
36
# File 'lib/i18n_flow/cli/search_command.rb', line 34

def output_format
  @output_format ||= options['format'] || DEFAULT_FORMAT
end

#patternObject



30
31
32
# File 'lib/i18n_flow/cli/search_command.rb', line 30

def pattern
  args[0]
end