Class: Rubocop::Options

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

Overview

This class handles command line options.

Constant Summary collapse

DEFAULT_FORMATTER =
'progress'

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



10
11
12
# File 'lib/rubocop/options.rb', line 10

def initialize
  @options = {}
end

Instance Method Details

#parse(args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rubocop/options.rb', line 14

def parse(args)
  ignore_dropped_options(args)
  convert_deprecated_options(args)

  OptionParser.new do |opts|
    opts.banner = 'Usage: rubocop [options] [file1, file2, ...]'

    option(opts, '--only COP', 'Run just one cop.') do
      validate_only_option
    end

    option(opts, '-c', '--config FILE', 'Specify configuration file.')

    add_formatting_options(opts, args)

    option(opts, '-r', '--require FILE', 'Require Ruby file.') do |f|
      require f
    end

    add_boolean_flags(opts)
  end.parse!(args)

  [@options, args]
end