Sha256: 31ef2745fc17f97b51e78afc90221a5508fa2fb95d272c61094786bb0a3abf04

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

require 'thor'

module PmdTranslateCheckstyleFormat
  class CLI < Thor
    include ::PmdTranslateCheckstyleFormat::Translate
    desc 'translate', 'Exec Translate'
    option :data
    option :file
    def translate
      data = fetch_data(options)
      xml = parse(data)
      checkstyle = trans(xml)
      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

2 entries across 2 versions & 1 rubygems

Version Path
pmd_translate_checkstyle_format-0.1.1 lib/pmd_translate_checkstyle_format/cli.rb
pmd_translate_checkstyle_format-0.1.0 lib/pmd_translate_checkstyle_format/cli.rb