Class: I18nFlow::CLI::LintCommand

Inherits:
CommandBase show all
Defined in:
lib/i18n_flow/cli/lint_command.rb,
lib/i18n_flow/cli/lint_command/ascii_renderer.rb,
lib/i18n_flow/cli/lint_command/markdown_renderer.rb

Defined Under Namespace

Classes: AsciiRenderer, MarkdownRenderer

Constant Summary collapse

DEFAULT_FORMAT =
'ascii'

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

#invoke!Object



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

def invoke!
  validator.validate!

  case output_format
  when 'ascii'
    puts AsciiRenderer.new(validator.errors, color: color_enabled?).render
  when 'markdown'
    puts MarkdownRenderer.new(validator.errors, url_formatter: url_formatter).render
  else
    exit_with_message(1, 'Unsupported format: %s' % [output_format])
  end

  exit validator.errors.size.zero? ? 0 : 1
end

#output_formatObject



27
28
29
# File 'lib/i18n_flow/cli/lint_command.rb', line 27

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

#url_formatterObject



31
32
33
34
35
# File 'lib/i18n_flow/cli/lint_command.rb', line 31

def url_formatter
  return @url_formatter if @url_formatter
  @url_formatter = options['url-formatter']
  @url_formatter ||= "file://#{I18nFlow.config.base_path}/%f#%l"
end