class Pry::CommandProcessor

def execute_command(target, action, options, *args)

Parameters:
  • args (Array) -- The command arguments.
  • options (Hash) -- The options to set on the Commands object.
  • action (Proc) -- The proc that implements the command.
  • target (Binding) -- The target of the Pry session.
def execute_command(target, action, options, *args)
  # set some useful methods to be used by the action blocks
  commands.opts = options
  commands.target = target
  commands.output = output
  case action.arity <=> 0
  when -1
    # Use instance_exec() to make the `opts` method, etc available
    ret_val = commands.instance_exec(*args, &action)
  when 1, 0
    # ensure that we get the right number of parameters
    # since 1.8.7 complains about incorrect arity (1.9.2
    # doesn't care)
    args_with_corrected_arity = args.values_at *0..(action.arity - 1)
    ret_val = commands.instance_exec(*args_with_corrected_arity, &action)
  end
  # Tick, tock, im getting rid of this shit soon.
  options[:val].clear
  
  ret_val
end