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.

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.

Parameters:

  • argv (Array<String>)


14
15
16
# File 'lib/serverkit/command.rb', line 14

def initialize(argv)
  @argv = argv
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/serverkit/command.rb', line 18

def call
  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