Sha256: c8065cbc779643743b7dbfe762eceb2c38f9fae78e463a05e3b8e51c578a103e

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

module RuboCop
  module Select
    class CLI
      attr_reader :options, :config_store, :output

      def initialize
        @options = {}
        @config_store = ::RuboCop::ConfigStore.new
        @output = $stdout
      end
      # Entry point for the application logic. Here we
      # do the command line arguments processing and inspect
      # the target files
      # @return [Fixnum] UNIX exit code
      def run(args = ARGV)
        @options, paths = ::RuboCop::Options.new.parse(args)
        act_on_options

        target_finder = ::RuboCop::TargetFinder.new(@config_store)
        full_scan_files = target_finder.find('')
        @output.puts File.intersect(full_scan_files, Dir.pwd, paths, Dir.pwd)
        0
      rescue StandardError => e
        $stderr.puts e.message
        $stderr.puts e.backtrace
        return 1
      end

      private

      def act_on_options
        handle_exiting_options

        ConfigLoader.debug = @options[:debug]
        ConfigLoader.auto_gen_config = @options[:auto_gen_config]

        @config_store.options_config = @options[:config] if @options[:config]
      end

      def handle_exiting_options
        return unless ::RuboCop::Options::EXITING_OPTIONS.any? { |o| @options.key? o }

        puts RuboCop::Select.version(false) if @options[:version]
        puts RuboCop::Select.version(true) if @options[:verbose_version]
        exit(0)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-select-2.0.0 lib/rubocop/select/cli.rb
rubocop-select-1.0.0 lib/rubocop/select/cli.rb
rubocop-select-0.1.1 lib/rubocop/select/cli.rb