Class: RuboCop::Select::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



6
7
8
9
10
# File 'lib/rubocop/select/cli.rb', line 6

def initialize
  @options = {}
  @config_store = ::RuboCop::ConfigStore.new
  @output = $stdout
end

Instance Attribute Details

#config_storeObject (readonly)

Returns the value of attribute config_store.



4
5
6
# File 'lib/rubocop/select/cli.rb', line 4

def config_store
  @config_store
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/rubocop/select/cli.rb', line 4

def options
  @options
end

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/rubocop/select/cli.rb', line 4

def output
  @output
end

Instance Method Details

#run(args = ARGV) ⇒ Fixnum

Entry point for the application logic. Here we do the command line arguments processing and inspect the target files

Returns:

  • (Fixnum)

    UNIX exit code



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubocop/select/cli.rb', line 15

def run(args = ARGV)
  @options, paths = ::RuboCop::Options.new.parse(args)
  act_on_options

  target_finder = ::RuboCop::TargetFinder.new(@config_store)
  full_scan_files = target_finder.find('')
  @output.puts File.intersect(full_scan_files, Dir.pwd, paths, Dir.pwd)
  0
rescue StandardError => e
  $stderr.puts e.message
  $stderr.puts e.backtrace
  return 1
end