lib/clamp/subcommand/execution.rb in clamp-1.0.1 vs lib/clamp/subcommand/execution.rb in clamp-1.1.0

- old
+ new

@@ -13,21 +13,21 @@ private def instantiate_subcommand(name) subcommand_class = find_subcommand_class(name) - parent_attribute_values = {} + subcommand = subcommand_class.new("#{invocation_path} #{name}", context) self.class.inheritable_attributes.each do |attribute| - if attribute.of(self).defined? - parent_attribute_values[attribute] = attribute.of(self).get - end + next unless attribute.of(self).defined? + attribute.of(subcommand).set(attribute.of(self).get) end - subcommand_class.new("#{invocation_path} #{name}", context, parent_attribute_values) + subcommand end 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 + subcommand_def = self.class.find_subcommand(name) + return subcommand_def.subcommand_class if subcommand_def + subcommand_missing(name) end end end