Class: Serverkit::Command

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

Constant Summary collapse

ACTION_NAMES =
%w(
  apply
  check
)

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.

Parameters:

  • argv (Array<String>)


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

def initialize(argv)
  @argv = argv
end

Instance Method Details

#call ⇒ Object



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

def call
  case
  when has_no_action_name?
    abort_for_missing_action_name
  when has_unknown_action_name?
    abort_for_unknown_action_name
  when action_name == "apply"
    apply
  when action_name == "check"
    check
  end
rescue Slop::MissingOptionError => exception
  abort "Error: #{exception}"
end