Sha256: 19b7bf1d08237210625bed8d982594532d540c3ab944bc9e7b5d8479e07f2ccb

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

Contents

class Thor
  class Command

    # By default, a command invokes a method in the thor class. You can change this
    # implementation to create custom commands.
    # Source: https://github.com/erikhuda/thor/blob/master/lib/thor/command.rb
    # Trace:
    # 1. Base_Class.start
    # 2. Thor_Class.dispatch
    #   - (new) Base.initialize -> with options
    # 3. Base_Instance.invoke_command (invocation.rb)
    # 4. Command_Instance.run
    # @note: modified so it integrates input/output for custom Pipe
    def run(instance, args = [])
      arity = nil

      if private_method?(instance)
        result = instance.class.handle_no_command_error(name)
      elsif public_method?(instance)
        arity = instance.method(name).arity
        result = instance.__send__(name, *args)
      elsif local_method?(instance, :method_missing)
        result = instance.__send__(:method_missing, name.to_sym, *args)
      else
        result = instance.class.handle_no_command_error(name)
      end

      result
    rescue ArgumentError => e
      handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
    rescue NoMethodError => e
      handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (raise e)
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eco-helpers-0.8.3 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.8.2 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.8.1 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.7.2 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.7.1 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.17 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.16 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.15 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.13 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.12 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.11 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.9 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.8 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.7 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.6 lib/eco/common/meta_thor/thor/command.rb
eco-helpers-0.6.5 lib/eco/common/meta_thor/thor/command.rb