Sha256: f52c80d07629cca088551da1909bf7f9e38abe9dfb68fcc08580b554d31f5f54

Contents?: true

Size: 678 Bytes

Versions: 6

Compression:

Stored size: 678 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-2.9.2 lib/rubycritic/cli/application.rb
rubycritic-2.9.1 lib/rubycritic/cli/application.rb
rubycritic-2.9.0 lib/rubycritic/cli/application.rb
rubycritic-2.8.0 lib/rubycritic/cli/application.rb
rubycritic-2.7.1 lib/rubycritic/cli/application.rb
rubycritic-2.7.0 lib/rubycritic/cli/application.rb