class CodeKeeper::Cli

Offers cli interface and execute measurement.

Constants

ERROR_CODE
GENERAL_ERROR_CODE
INTERRUPTION_CODE
SUCCESS_CODE

Public Class Methods

run(paths) click to toggle source
# File lib/code_keeper/cli.rb, line 11
def self.run(paths)
  if paths.empty?
    puts 'Specify at least one argument, a file or a directory.'
    return ERROR_CODE
  end

  result = CodeKeeper::Scorer.keep(paths)

  puts ::CodeKeeper::Formatter.format(result)
  SUCCESS_CODE
rescue Interrupt
  puts 'Exiting...'
  INTERRUPTION_CODE
rescue CodeKeeper::TargetFileNotFoundError => e
  puts e.message
  ERROR_CODE
rescue StandardError => e
  puts e.message
  GENERAL_ERROR_CODE
end