class PryRemote::CLI
Parses arguments and allows to start the client.
def initialize(args = ARGV)
def initialize(args = ARGV) params = Pry::Slop.parse args, :help => true do banner "#$PROGRAM_NAME [OPTIONS]" on :s, :server=, "Host of the server (#{DefaultHost})", :argument => :optional, :default => DefaultHost on :p, :port=, "Port of the server (#{DefaultPort})", :argument => :optional, :as => Integer, :default => DefaultPort on :w, :wait, "Wait for the pry server to come up", :default => false on :c, :capture, "Captures $stdout and $stderr from the server (true)", :default => true on :f, "Disables loading of .pryrc and its plugins, requires, and command history " end exit if params.help? @host = params[:server] @port = params[:port] @wait = params[:wait] @capture = params[:capture] Pry.initial_session_setup unless params[:f] end
def run(input = Pry.config.input, output = Pry.config.output)
-
output(IO) -- Object pry-debug will send its output to -
input(IO) -- Object holding input for pry-remote
def run(input = Pry.config.input, output = Pry.config.output) local_ip = UDPSocket.open {|s| s.connect(@host, 1); s.addr.last} DRb.start_service "druby://#{local_ip}:0" client = DRbObject.new(nil, uri) input = IOUndumpedProxy.new(input) output = IOUndumpedProxy.new(output) begin client.input = input client.output = output rescue DRb::DRbConnError => ex if wait? sleep 1 retry else raise ex end end if capture? client.stdout = $stdout client.stderr = $stderr end client.thread = Thread.current sleep DRb.stop_service end
def uri
-
(String)- URI for DRb
def uri "druby://#{host}:#{port}" end