Class: TextToCheckstyle::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/text_to_checkstyle/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/text_to_checkstyle/cli.rb', line 5

def self.exit_on_failure?
  true
end

Instance Method Details

#convertObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/text_to_checkstyle/cli.rb', line 26

def convert
  setup_logger(options)
  data = \
      if options[:data]
        options[:data]
      elsif options[:file]
        File.read(options[:file])
      elsif !$stdin.tty?
        ARGV.clear
        ARGF.read
      end

  fail(NoInputError) if !data || data.empty?
  params = {
    name: options[:name],
    line: options[:line],
    column: options[:column],
    severity: options[:severity],
    source: options[:source]
  }
  puts ::TextToCheckstyle::Converter.convert(data, params)
rescue StandardError => e
  suggest_messages(options)
  raise e
end

#versionObject



12
13
14
# File 'lib/text_to_checkstyle/cli.rb', line 12

def version
  puts "TextToCheckstyle version #{::TextToCheckstyle::VERSION}"
end