Class: RuboCop::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/options.rb

Overview

This class handles command line options.

Constant Summary collapse

EXITING_OPTIONS =
[:version, :verbose_version, :show_cops].freeze
DEFAULT_MAXIMUM_EXCLUSION_ITEMS =
15

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



12
13
14
15
# File 'lib/rubocop/options.rb', line 12

def initialize
  @options = {}
  @validator = OptionsValidator.new(@options)
end

Instance Method Details

#parse(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubocop/options.rb', line 17

def parse(args)
  define_options(args).parse!(args)
  # The --no-color CLI option sets `color: false` so we don't want the
  # `no_color` key, which is created automatically.
  @options.delete(:no_color)

  @validator.validate_compatibility

  if @options[:stdin] && !args.one?
    raise ArgumentError, '-s/--stdin requires exactly one path.'
  end

  [@options, args]
end