Class: Pione::Command::BasicCommand

Inherits:
Rootage::StandardCommand show all
Defined in:
lib/pione/command/basic-command.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Rootage::Command

#argument_definition, #argv, #option_definition

Attributes inherited from Rootage::Scenario

#args, #current_phase, #exit_status, #info, #model, #running_thread

Instance Method Summary collapse

Methods inherited from Rootage::StandardCommand

execution, setup, #terminate, termination

Methods inherited from Rootage::Command

#<<, define_subcommand, #exit, has_subcommands?, inherited, init, #initialize, #run, #scenario_name, toplevel?

Methods inherited from Rootage::Scenario

#<<, define_action, #exit, inherited, #initialize, make, require, #run, run, scenario_name

Methods included from Rootage::ScenarioInterface

#define, #define_phase, #desc, #phase, #phase_class, #process_context_class, #scenario_name

Constructor Details

This class inherits a constructor from Rootage::Command

Instance Method Details

#abort(msg_or_exception, option = {}) ⇒ Object

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



40
41
42
43
44
45
46
47
48
49
# 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_nameObject

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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