Class: CodeKeeper::Cli

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

Overview

Offers cli interface and execute measurement.

Constant Summary collapse

SUCCESS_CODE =
0
GENERAL_ERROR_CODE =
1
ERROR_CODE =
2
INTERRUPTION_CODE =
128 + Signal.list['INT']

Class Method Summary collapse

Class Method Details

.run(paths) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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