class MindControl::REPL
Public Class Methods
new( target, options = {} )
click to toggle source
Public Instance Methods
start( stdin, stdout )
click to toggle source
Start REPL
session.
@param [IO] stdin The object to use for input. @param [IO] stdout The object to use for output.
# File lib/mind_control/repl.rb, line 27 def start( stdin, stdout ) # NB: We cannot use Readline, because it always uses STDOUT / STDIN. input = CoollineAdapter.new( stdin, stdout ) # Default command set commands = @options[ :commands ] || ::Pry::CommandSet.new.import( ::Pry::Commands ) # Import our MindControl commands commands.import MindControl::PryCommands # Target can be callable target = @target.respond_to?( :call ) ? @target.call : @target # NB: input/input can't be changed via pry options! pry = ::Pry.new @options.merge( :commands => commands, :input => input, :output => stdout ) # Store pry instance in thread-local context so that we can later determine # whether we are running inside MindControl session or not. ::Pry.current[ :mind_control_pry_instance ] = pry # Start session pry.repl target end