Sha256: 677ed7cbaa64bceb5a7f1e1c08ea10a223da0333f1e56b41fd430b1a36c2d87b

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'rubocop/git'
require 'optparse'

module RuboCop
  module Git
    class CLI
      def run(args = ARGV)
        options = parse_arguments(args)
        Runner.new.run(options)
      end

      private

      def parse_arguments(args)
        options = {}

        OptionParser.new do |opt|
          opt.on('-c', '--config FILE',
                 'Specify configuration file') do |config|
            options[:config] = config
          end

          opt.on('-D', '--display-cop-names',
                 'Display cop names in offense messages') do
            options[:rubocop] ||= {}
            options[:rubocop][:display_cop_names] = true
          end

          opt.on('--cached', 'git diff --cached') do
            options[:cached] = true
          end

          opt.on('--staged', 'synonym of --cached') do
            options[:cached] = true
          end

          opt.on('--hound',
                 'Hound compatibility mode (require rubocop 0.22.0)') do
            options[:hound] = true
          end

          opt.parse(args)
        end

        options
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-git-0.0.1 lib/rubocop/git/cli.rb