Class: Tailor::CLI

Inherits:
Object
  • Object
show all
Includes:
LogSwitch::Mixin
Defined in:
lib/tailor/cli.rb,
lib/tailor/cli/options.rb

Overview

The Command-Line Interface worker. Execution from the command line comes through here.

Defined Under Namespace

Classes: Options

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.

Parameters:

  • args (Array)

    Arguments from the command-line.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tailor/cli.rb', line 20

def initialize(args)
  Tailor::Logger.log = false
  options = Options.parse!(args)

  @configuration = Configuration.new(args, options)
  @configuration.load!

  if options.show_config
    @configuration.show
    exit
  end

  @critic = Critic.new
  @reporter = Reporter.new(@configuration.formatters)
end

Class Method Details

.run(args) ⇒ Object

The main method of execution from the command line.



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

def self.run(args)
  new(args).execute!
end

Instance Method Details

#execute!Boolean

This checks all of the files detected during the configuration gathering process, then hands results over to the Reporter to be reported.

Returns:

  • (Boolean)

    true if no problems were detected; false if there were.



41
42
43
44
45
46
47
48
49
# File 'lib/tailor/cli.rb', line 41

def execute!
  @critic.critique(@configuration.file_sets) do |problems_for_file, label|
    @reporter.file_report(problems_for_file, label)
  end

  @reporter.summary_report(@critic.problems)

  @critic.problem_count(:error) > 0
end