Sha256: 1af419d94e2afb0b180802f6eab6fee878cc5a6719e0ce9d4df9a6a8e9eb0010

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

require 'thor'

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

2 entries across 2 versions & 1 rubygems

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