Class: Serverkit::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/serverkit/command.rb

Overview

Command clsas takes care of command line interface. It builds and runs an Action object from given command line arguements.

Constant Summary collapse

LOG_LEVELS_TABLE =
{
  nil => Logger::INFO,
  "DEBUG" => Logger::DEBUG,
  "ERROR" => Logger::ERROR,
  "FATAL" => Logger::FATAL,
  "INFO" => Logger::INFO,
  "WARN" => Logger::WARN,
}

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.

Parameters:

  • argv (Array<String>)


24
25
26
# File 'lib/serverkit/command.rb', line 24

def initialize(argv)
  @argv = argv
end

Instance Method Details

#callObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/serverkit/command.rb', line 28

def call
  setup
  case action_name
  when nil
    raise Errors::MissingActionNameArgumentError
  when "apply"
    apply
  when "check"
    check
  when "inspect"
    _inspect
  when "validate"
    validate
  else
    raise Errors::UnknownActionNameError, action_name
  end
rescue Errors::Base, Slop::MissingArgumentError, Slop::MissingOptionError => exception
  abort "Error: #{exception}"
end