Sha256: d681d4be4bb7ffb89a429e8681625a6a213c11f2a2ada1cc835b5a9fa66864bc

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 Bytes

Contents

require 'thor'

module AndroidLintTranslateCheckstyleFormat
  class CLI < Thor
    include ::AndroidLintTranslateCheckstyleFormat::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

4 entries across 4 versions & 1 rubygems

Version Path
android_lint_translate_checkstyle_format-0.2.0 lib/android_lint_translate_checkstyle_format/cli.rb
android_lint_translate_checkstyle_format-0.1.2 lib/android_lint_translate_checkstyle_format/cli.rb
android_lint_translate_checkstyle_format-0.1.1 lib/android_lint_translate_checkstyle_format/cli.rb
android_lint_translate_checkstyle_format-0.1.0 lib/android_lint_translate_checkstyle_format/cli.rb