Class: Slimembedcop::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/slimembedcop/option.rb

Overview

Command line options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Option

Returns a new instance of Option.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/slimembedcop/option.rb', line 9

def initialize(argv)
  opt = OptionParser.new
  @version = false
  @autocorrect = false
  @forced_config_path = nil
  @color = nil
  @debug = false
  @default_config_path = File.expand_path('../default.yml', __dir__)
  @default_path_patterns = %w[**/*.slim].freeze

  opt.banner = 'Usage: slimembedcop [options] [file1, file2, ...]'
  opt.on('-v', '--version', 'Display version.') { @version = true }
  opt.on('-a', '--autocorrect', 'Autocorrect offenses.') { @autocorrect = true }
  opt.on('-c', '--config=', 'Specify configuration file.') { |path| @forced_config_path = path }
  opt.on('--[no-]color', 'Force color output on or off.') { |value| @color = value }
  opt.on('-d', '--debug', 'Display debug info.') { |value| @debug = value }
  @args = opt.parse(argv)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def args
  @args
end

#autocorrectObject (readonly)

Returns the value of attribute autocorrect.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def autocorrect
  @autocorrect
end

#colorObject (readonly)

Returns the value of attribute color.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def color
  @color
end

#debugObject (readonly)

Returns the value of attribute debug.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def debug
  @debug
end

#default_config_pathObject (readonly)

Returns the value of attribute default_config_path.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def default_config_path
  @default_config_path
end

#default_path_patternsObject (readonly)

Returns the value of attribute default_path_patterns.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def default_path_patterns
  @default_path_patterns
end

#forced_config_pathObject (readonly)

Returns the value of attribute forced_config_path.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def forced_config_path
  @forced_config_path
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/slimembedcop/option.rb', line 6

def version
  @version
end