Class: RuboCop::Options
- Inherits:
-
Object
- Object
- RuboCop::Options
- Defined in:
- lib/rubocop/options.rb
Overview
This class handles command line options.
Constant Summary collapse
- EXITING_OPTIONS =
%i[version verbose_version show_cops].freeze
- DEFAULT_MAXIMUM_EXCLUSION_ITEMS =
15
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #parse(command_line_args) ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
14 15 16 17 |
# File 'lib/rubocop/options.rb', line 14 def initialize @options = {} @validator = OptionsValidator.new(@options) end |
Instance Method Details
#parse(command_line_args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/options.rb', line 19 def parse(command_line_args) args = args_from_file.concat(args_from_env).concat(command_line_args) (args).parse!(args) @validator.validate_compatibility if @options[:stdin] # The parser has put the file name given after --stdin into # @options[:stdin]. The args array should be empty. if args.any? raise ArgumentError, '-s/--stdin requires exactly one path.' end # We want the STDIN contents in @options[:stdin] and the file name in # args to simplify the rest of the processing. args = [@options[:stdin]] @options[:stdin] = $stdin.binmode.read end [@options, args] end |