def self.start(target=nil, options={})
return if ENV['DISABLE_PRY']
options = options.to_hash
if in_critical_section?
output.puts "ERROR: Pry started inside Pry."
output.puts "This can happen if you have a binding.pry inside a #to_s or #inspect function."
return
end
options[:target] = Pry.binding_for(target || toplevel_binding)
options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks)
initial_session_setup
if options[:backtrace].nil?
options[:backtrace] = caller
if options[:backtrace].first =~ /pry.*core_extensions.*pry/
options[:backtrace].shift
end
end
driver = options[:driver] || Pry::REPL
driver.start(options)
rescue Pry::TooSafeException
puts "ERROR: Pry cannot work with $SAFE > 0"
raise
end