Class: Skunk::Cli::Application

Inherits:
RubyCritic::Cli::Application
  • Object
show all
Defined in:
lib/skunk/cli/application.rb

Overview

Knows how to execute command line commands :reek:InstanceVariableAssumption

Constant Summary collapse

COVERAGE_FILE =
"coverage/.resultset.json"

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.



19
20
21
# File 'lib/skunk/cli/application.rb', line 19

def initialize(argv)
  @options = Skunk::Cli::Options.new(argv)
end

Instance Method Details

#executeObject

:reek:UncommunicativeVariableName



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/skunk/cli/application.rb', line 24

def execute
  warn_coverage_info unless File.exist?(COVERAGE_FILE)

  # :reek:NilCheck
  @parsed_options = @options.parse.to_h
  command = Skunk::CommandFactory.create(@parsed_options)
  reporter = command.execute

  print(reporter.status_message)
  if command.sharing?
    share_status_message = command.share(reporter)
    print(share_status_message)
  end

  reporter.status
rescue OptionParser::InvalidOption => e
  warn "Error: #{e}"
  STATUS_ERROR
end