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.
57 58 59 |
# File 'lib/rubocop/options.rb', line 57 def initialize @options = {} end |
Instance Method Details
#parse(args) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rubocop/options.rb', line 61 def parse(args) (args) (args) OptionParser.new do |opts| opts. = 'Usage: rubocop [options] [file1, file2, ...]' option(opts, '--only [COP1,COP2,...]') do |list| @options[:only] = list.split(',').map do |c| Cop::Cop.qualified_cop_name(c, '--only option') end validate_only_option end (opts, args) (opts) option(opts, '-r', '--require FILE') { |f| require f } 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 |