diff options
Diffstat (limited to 'lib/pry/command.rb')
| -rw-r--r-- | lib/pry/command.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/pry/command.rb b/lib/pry/command.rb index b10b6147..31d4e1bc 100644 --- a/lib/pry/command.rb +++ b/lib/pry/command.rb @@ -6,6 +6,20 @@ class Pry # {Pry::CommandSet#command} which creates a BlockCommand or {Pry::CommandSet#create_command} # which creates a ClassCommand. Please don't use this class directly. class Command + class Pipe + attr_accessor :in + attr_accessor :out + attr_accessor :use_pipe_for_output + + def read + @in + end + + def write(obj) + @out = obj + end + end + extend Helpers::DocumentationHelpers # represents a void return value for a command @@ -185,6 +199,9 @@ class Pry attr_accessor :command_set attr_accessor :_pry_ + # @return [Pry::Command::Pipe] The pipe object. + attr_accessor :pipe + # The block we pass *into* a command so long as `:takes_block` is # not equal to `false` # @example @@ -193,6 +210,14 @@ class Pry # end attr_accessor :command_block + def in_pipe? + !!pipe.in + end + + def out_pipe? + !!pipe.use_pipe_for_output + end + # 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 @@ -225,6 +250,7 @@ class Pry # Instantiate a command, in preparation for calling it. # @param [Hash] context The runtime context to use with this command. def initialize(context={}) + self.pipe = Pipe.new self.context = context self.target = context[:target] self.output = context[:output] |
