Sha256: cf5e9e2bce96022faead45bf8ecafac87026fb61ac876a731d1df5ab2116990e

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

require 'thor'

module OclintTranslateCheckstyleFormat
  class CLI < Thor
    include ::OclintTranslateCheckstyleFormat::Translate
    desc 'translate', 'Exec Translate'
    option :data
    option :file
    def translate
      data = fetch_data(options)
      parsed_data = parse(data)
      checkstyle = trans(parsed_data)
      checkstyle.write(STDOUT, 2)
    end

    no_commands do
      def fetch_data(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?

        data
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oclint_translate_checkstyle_format-0.1.0 lib/oclint_translate_checkstyle_format/cli.rb