class Pione::Command::BasicCommand

BasicCommand provides PIONE’s basic command structure. PIONE commands have 4 phases: “init”, “setup”, “execution”, “termination”. Concrete commands implement some processings as each phases.

Public Instance Methods

abort(msg_or_exception, option={}) click to toggle source

Exit the running command and return failure status. Note that this method enters termination phase before it exits.

Calls superclass method
# File lib/pione/command/basic-command.rb, line 40
def abort(msg_or_exception, option={})
  pos = option[:pos] || caller(1).first

  # hide the message because some option errors are meaningless
  if msg_or_exception.is_a?(HideableOptionError)
    Log::Debug.system(msg_or_exception.message, pos)
  end

  super
end
program_name() click to toggle source

Return the program name with the front URI and the parent’s front URI.

# File lib/pione/command/basic-command.rb, line 18
def program_name
  additions = []

  # front server URI
  if model[:front]
    additions << "front: %s" % model[:front].uri
  end

  # parent front server URI
  if model[:parent_front]
    additions << "parent: %s" % model[:parent_front].uri
  end

  if additions.empty?
    name
  else
    "%s (%s)" % [name, additions.join(", ")]
  end
end

Private Instance Methods

exit_process() click to toggle source
# File lib/pione/command/basic-command.rb, line 53
def exit_process
  model[:front].terminate if model[:front]
  Global.system_logger.terminate
end