Sha256: dd863e4a8f7d926acfe3adb2f713a6b0020d77f63a11f25504989f1ae23bcd6d

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

require 'thor'

module BrakemanTranslateCheckstyleFormat
  class CLI < Thor
    include ::BrakemanTranslateCheckstyleFormat::Translate
    desc 'translate', 'Exec Translate'
    option :data
    option :file
    def translate
      data = fetch_data(options)
      json = parse(data)
      checkstyle = trans(json)
      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
brakeman_translate_checkstyle_format-0.0.1 lib/brakeman_translate_checkstyle_format/cli.rb