Sha256: ae93a19701ca012311599d3ef6385f4bd4f78577b32dae245d47f713961d2cfe

Contents?: true

Size: 938 Bytes

Versions: 71

Compression:

Stored size: 938 Bytes

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 = {}
        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

      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

71 entries across 67 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb