Sha256: 0f463db43aee3d5689d9c90c30303a9f9404a1b1d08cd8a48f7755a812146ee3

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

module Brigadier
  module Commands
    class Command
      include Base

      attr_reader :instance

      def initialize(instance, block)
        @instance = instance
        @block = block
      end

      def execute(args, full_args, klasses)
        process_args(args, instance)

        assign_toggles_from(available_toggles)
        assign_options_from(available_options)
        assign_arguments_from(available_arguments)

        # FIXME
        objs = (full_args.count == 1) ? klasses : klass
        return if display_help_if_requested(objs, full_args)

        ensure_parameters_defined!(available_options, available_arguments)

        instance.instance_eval(&block)
      end

      private

        attr_reader :block

        # FIXME
        def klass
          @klass ||= instance
        end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brigadier-0.1.2 lib/brigadier/commands/command.rb
brigadier-0.1.1 lib/brigadier/commands/command.rb