class Tailor::CLI

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

Attributes

configuration[R]

@return [Tailor::Configuration]

Public Class Methods

new(args) click to toggle source

@param [Array] args Arguments from the command-line.

# File lib/tailor/cli.rb, line 26
def initialize(args)
  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
run(args) click to toggle source

The main method of execution from the command line.

@param [Array] args Arguments from the command-line.

# File lib/tailor/cli.rb, line 21
def self.run(args)
  new(args).execute!
end

Public Instance Methods

execute!() click to toggle source

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

@return [Boolean] true if no problems were detected; false if there

were.
# File lib/tailor/cli.rb, line 45
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,
    output_file: @configuration.output_file)

  @critic.problem_count(:error) > 0
end
result() click to toggle source

Critiques all file sets, then returns the problems found as a result.

@return [Hash{String => Array}] The list of problems, where the keys are

the file names in which the problems were found, and the values are the
respective lists of problems for each file.
# File lib/tailor/cli.rb, line 61
def result
  @critic.critique(@configuration.file_sets)
  @critic.problems
end