Class Pry::Command
In: lib/pry/command.rb
Parent: Object

The super-class of all commands, new commands should be created by calling {Pry::CommandSet#command} which creates a BlockCommand or {Pry::CommandSet#create_command} which creates a ClassCommand. Please don‘t use this class directly.

Methods

Included Modules

Pry::Helpers::BaseHelpers Pry::Helpers::CommandHelpers

Classes and Modules

Module Pry::Command::VOID_VALUE

Constants

VOID_VALUE = Object.new   represents a void return value for a command

External Aliases

command_options -> options
  backward compatibility
command_options= -> options=

Attributes

_pry_  [RW] 
arg_string  [RW] 
block  [RW] 
captures  [RW] 
command_options  [W] 
command_set  [RW] 
context  [RW] 
description  [W] 
eval_string  [RW] 
name  [RW] 
output  [RW]  Properties of one execution of a command (passed by {Pry#run_command} as a hash of context and expanded in {initialize}
target  [RW] 

Public Class methods

Define or get the command‘s banner

Define or get the command‘s options

Define or get the command‘s description

Store hooks to be run before or after the command body. @see {Pry::CommandSet#before_command} @see {Pry::CommandSet#after_command}

Should this command be called for the given line?

@param String a line input at the REPL @return Boolean

Instantiate a command, in preparation for calling it.

@param Hash context The runtime context to use with this command.

Create a new command with the given properties.

@param String name the name of the command @param String description the description to appear in {help} @param Hash options behavioural options (@see {Pry::CommandSet#command}) @param Module helpers a module of helper functions to be included. @param Proc &block (optional, a block, used for BlockCommands)

@return Class (a subclass of Pry::Command)

Public Instance methods

Run the command with the given {args}.

This is a public wrapper around {call} which ensures all preconditions are met.

@param *[String] the arguments to pass to this command. @return Object the return value of the {call} method, or Command::VOID_VALUE

Display a warning if a command collides with a local/method in the current scope. @param [String] command_name_match The name of the colliding command. @param [Binding] target The current binding context.

Are all the gems required to use this command installed?

@return Boolean

Revaluate the string (str) and perform interpolation. @param [String] str The string to reevaluate with interpolation.

@return [String] The reevaluated string with interpolations

  applied (if any).

Make those properties accessible to instances

Process a line that Command.matches? this command.

@param String the line to process @return Object or Command::VOID_VALUE

Run a command from another command. @param [String] command_string The string that invokes the command @param [Array] args Further arguments to pass to the command @example

  run "show-input"

@example

  run ".ls"

@example

  run "amend-line",  "5", 'puts "hello world"'

The value of {self} inside the {target} binding.

Extract necessary information from a line that Command.matches? this command.

@param String the line of input @return [

  String   the command name used, or portion of line that matched the command_regex
  String   a string of all the arguments (i.e. everything but the name)
  Array    the captures caught by the command_regex
  Array    args the arguments got by splitting the arg_string

]

[Validate]