Sha256: 1a09278aed85db37234c1ef84a250e3703fc69c9f9de32ac81c7f4b19381577f
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Clamp module Subcommand module Execution # override default Command behaviour def execute # delegate to subcommand subcommand = instatiate_subcommand(subcommand_name) subcommand.run(subcommand_arguments) end private def instatiate_subcommand(name) subcommand_class = find_subcommand_class(name) parent_attribute_values = {} inheritable_attributes.each do |option| if instance_variable_defined?(option.ivar_name) parent_attribute_values[option] = instance_variable_get(option.ivar_name) end end subcommand_class.new("#{invocation_path} #{name}", context, parent_attribute_values) end def inheritable_attributes self.class.recognised_options + self.class.parameters_before_subcommand end def find_subcommand_class(name) subcommand_def = self.class.find_subcommand(name) || signal_usage_error("No such sub-command '#{name}'") subcommand_def.subcommand_class end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clamp-0.6.0 | lib/clamp/subcommand/execution.rb |