Class: RuboBot::CLI

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

Overview

Entrypoint for running RuboBot from the CLI

Constant Summary collapse

STATUS_SUCCESS =
0
STATUS_FAILURE =
1

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths, configuration) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
# File 'lib/rubobot/cli.rb', line 14

def initialize(paths, configuration)
  @paths = paths
  @configuration = configuration
end

Class Method Details

.run(argv) ⇒ Object



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

def self.run(argv)
  options = Options.new(argv)
  new(options[:paths], Configuration.new(options)).run
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
# File 'lib/rubobot/cli.rb', line 19

def run
  return output(VERSION) if configuration.version?

  commit_message = Bot.new(configuration).autocorrect(paths)
  output(commit_message) if configuration.commit_message?
  STATUS_SUCCESS
rescue RuboBot::RuboCop::NoOffensesError
  STATUS_FAILURE
end