Class: EagerEye::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/eager_eye/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
# File 'lib/eager_eye/cli.rb', line 9

def initialize(argv = ARGV)
  @argv = argv
  @options = default_options
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



7
8
9
# File 'lib/eager_eye/cli.rb', line 7

def argv
  @argv
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/eager_eye/cli.rb', line 7

def options
  @options
end

Instance Method Details

#runObject



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

def run
  parse_options!
  return 0 if options[:help] || options[:version]

  issues = analyze

  if options[:suggest_fixes]
    fixer = AutoFixer.new(issues)
    fixer.suggest
    return 0
  end

  if options[:fix]
    fixer = AutoFixer.new(issues, interactive: !options[:force])
    fixer.run
    return 0
  end

  output_report(issues)
  exit_code(issues)
end