module Clamp::Subcommand::Execution

Public Instance Methods

execute() click to toggle source

override default Command behaviour

# File lib/clamp/subcommand/execution.rb, line 8
def execute
  # delegate to subcommand
  subcommand = instatiate_subcommand(subcommand_name)
  subcommand.run(subcommand_arguments)
end

Private Instance Methods

find_subcommand_class(name) click to toggle source
# File lib/clamp/subcommand/execution.rb, line 27
def find_subcommand_class(name)
  subcommand_def = self.class.find_subcommand(name) || signal_usage_error(Clamp.message(:no_such_subcommand, :name => name))
  subcommand_def.subcommand_class
end
instatiate_subcommand(name) click to toggle source
# File lib/clamp/subcommand/execution.rb, line 16
def instatiate_subcommand(name)
  subcommand_class = find_subcommand_class(name)
  parent_attribute_values = {}
  self.class.inheritable_attributes.each do |attribute|
    if attribute.of(self).defined?
      parent_attribute_values[attribute] = attribute.of(self).get
    end
  end
  subcommand_class.new("#{invocation_path} #{name}", context, parent_attribute_values)
end