Class: Daemon::Command

Inherits:
Object
  • Object
show all
Includes:
UserInterface
Defined in:
lib/onapp/engine/command.rb,
lib/onapp/engine/command/options.rb,
lib/onapp/engine/command/base_command.rb,
lib/onapp/engine/command/stop_command.rb,
lib/onapp/engine/command/start_command.rb,
lib/onapp/engine/command/status_command.rb,
lib/onapp/engine/command/user_interface.rb

Defined Under Namespace

Modules: UserInterface Classes: BaseCommand, Options, StartCommand, StatusCommand, StopCommand

Constant Summary

START =
'start'.freeze
STOP =
'stop'.freeze
STATUS =
'status'.freeze
COMMANDS =
[START, STOP, STATUS]

Instance Attribute Summary

Attributes included from UserInterface

#err, #out

Instance Method Summary (collapse)

Methods included from UserInterface

#error, #say

Constructor Details

- (Command) initialize(argv, out = $stdout, err = $stderr)

Returns a new instance of Command

Parameters:

  • argv (ARGV)

    Arguments

  • out (IO) (defaults to: $stdout)

    Stdout stream

  • err (IO) (defaults to: $stderr)

    Stderr stream



25
26
27
# File 'lib/onapp/engine/command.rb', line 25

def initialize(argv, out = $stdout, err = $stderr)
  @options = Options.new(argv, out, err)
end

Instance Method Details

- (Object) run

Parses options and launches command



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/onapp/engine/command.rb', line 30

def run
  exit(1) unless @options.parse!

  case @options.command
  when START
    StartCommand.new(@options).execute
  when STOP
    StopCommand.new(@options).execute
  when STATUS
    StatusCommand.new(@options).execute
  end
end