Sha256: 1cbd996d1b7f60cfb89554cbb90fcf2f34aff478f6c31171c6fe9bad63c6841e

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

require 'rubycritic'
require 'rubycritic/cli/options'
require 'rubycritic/command_factory'

module RubyCritic
  module Cli
    class Application
      STATUS_SUCCESS = 0
      STATUS_ERROR   = 1

      def initialize(argv)
        @options = Options.new(argv)
      end

      def execute
        parsed_options = @options.parse

        reporter = RubyCritic::CommandFactory.create(parsed_options.to_h).execute
        print(reporter.status_message)
        reporter.status
      rescue OptionParser::InvalidOption => error
        $stderr.puts "Error: #{error}"
        STATUS_ERROR
      end

      def print(message)
        $stdout.puts message
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubycritic-3.3.0 lib/rubycritic/cli/application.rb
rubycritic-3.2.3 lib/rubycritic/cli/application.rb
rubycritic-3.2.2 lib/rubycritic/cli/application.rb
rubycritic-3.2.1 lib/rubycritic/cli/application.rb