Class: Rubocop::Options
- Inherits:
-
Object
- Object
- Rubocop::Options
- Defined in:
- lib/rubocop/options.rb
Overview
This class handles command line options.
Constant Summary collapse
- DEFAULT_FORMATTER =
'progress'
- EXITING_OPTIONS =
[:version, :verbose_version, :show_cops]
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #parse(args) ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
11 12 13 |
# File 'lib/rubocop/options.rb', line 11 def initialize @options = {} end |
Instance Method Details
#parse(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/options.rb', line 15 def parse(args) (args) (args) OptionParser.new do |opts| opts. = 'Usage: rubocop [options] [file1, file2, ...]' option(opts, '--only COP', 'Run just one cop.') do validate_only_option end (opts, args) (opts, args) option(opts, '-r', '--require FILE', 'Require Ruby file.') do |f| require f end add_severity_option(opts) add_flags_with_optional_args(opts) add_boolean_flags(opts) end.parse!(args) if (incompat = @options.keys & EXITING_OPTIONS).size > 1 fail ArgumentError, "Incompatible cli options: #{incompat.inspect}" end [@options, args] end |