Class: RuboCop::CLI
- Inherits:
-
Object
- Object
- RuboCop::CLI
- Includes:
- Formatter::TextUtil
- Defined in:
- lib/rubocop/cli.rb
Overview
The CLI is a class responsible of handling all the command line interface logic.
Defined Under Namespace
Classes: Finished
Constant Summary collapse
- SKIPPED_PHASE_1 =
'Phase 1 of 2: run Metrics/LineLength cop (skipped ' \ 'because the default Metrics/LineLength:Max is ' \ 'overridden)'.freeze
Instance Attribute Summary collapse
-
#config_store ⇒ Object
readonly
Returns the value of attribute config_store.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
-
#run(args = ARGV) ⇒ Integer
Entry point for the application logic.
-
#trap_interrupt(runner) ⇒ Object
rubocop:enable Metrics/MethodLength.
Methods included from Formatter::TextUtil
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
18 19 20 21 |
# File 'lib/rubocop/cli.rb', line 18 def initialize @options = {} @config_store = ConfigStore.new end |
Instance Attribute Details
#config_store ⇒ Object (readonly)
Returns the value of attribute config_store.
16 17 18 |
# File 'lib/rubocop/cli.rb', line 16 def config_store @config_store end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/rubocop/cli.rb', line 16 def @options end |
Instance Method Details
#run(args = ARGV) ⇒ Integer
Entry point for the application logic. Here we do the command line arguments processing and inspect the target files.
rubocop:disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cli.rb', line 33 def run(args = ARGV) @options, paths = Options.new.parse(args) apply_default_formatter execute_runners(paths) rescue RuboCop::Error => e warn Rainbow("Error: #{e.}").red return 2 rescue Finished return 0 rescue IncorrectCopNameError => e warn e. return 2 rescue StandardError, SyntaxError, LoadError => e warn e. warn e.backtrace return 2 end |
#trap_interrupt(runner) ⇒ Object
rubocop:enable Metrics/MethodLength
54 55 56 57 58 59 60 61 |
# File 'lib/rubocop/cli.rb', line 54 def trap_interrupt(runner) Signal.trap('INT') do exit!(1) if runner.aborting? runner.abort warn warn 'Exiting... Interrupt again to exit immediately.' end end |