Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::CLI

The CLI is a class responsible of handling all the command line interface logic.

Attributes

config_store[R]
options[R]
wants_to_quit[RW]

If set true while running, RuboCop will abort processing and exit gracefully.

wants_to_quit?[RW]

If set true while running, RuboCop will abort processing and exit gracefully.

Public Class Methods

new() click to toggle source
# File lib/rubocop/cli.rb, line 13
def initialize
  @options = {}
  @config_store = ConfigStore.new
end

Public Instance Methods

run(args = ARGV) click to toggle source

Entry point for the application logic. Here we do the command line arguments processing and inspect the target files @return [Fixnum] UNIX exit code

# File lib/rubocop/cli.rb, line 22
def run(args = ARGV)
  trap_interrupt

  @options, remaining_args = Options.new.parse(args)
  act_on_options
  target_files = target_finder.find(remaining_args)

  inspector = FileInspector.new(@options)
  any_failed = inspector.process_files(target_files, @config_store) do
    wants_to_quit?
  end
  inspector.display_error_summary

  !any_failed && !wants_to_quit ? 0 : 1
rescue Cop::AmbiguousCopName => e
  $stderr.puts "Ambiguous cop name #{e.message} needs namespace "                     'qualifier.'
  return 1
rescue => e
  $stderr.puts e.message
  $stderr.puts e.backtrace
  return 1
end
trap_interrupt() click to toggle source
# File lib/rubocop/cli.rb, line 46
def trap_interrupt
  Signal.trap('INT') do
    exit!(1) if wants_to_quit?
    self.wants_to_quit = true
    $stderr.puts
    $stderr.puts 'Exiting... Interrupt again to exit immediately.'
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.