diff --git a/CHANGELOG b/CHANGELOG index 8a3942bf..d5248602 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * got rid of Pry#null_input? since all that was needed was eval_string.empty? * cd command now supports complex syntax: cd ../@y/y/../z * JRuby is no longer a 2nd class citizen, almost full JRuby support, passing 100% tests +* added Pry::NAV_PROMPT (great new navigation prompt, per robgleeson) and Pry::SIMPLE_PRINT for simple (IRB-style) print output (just using inspect) */7/2011 version 0.9.3 * cat --ex (cats 5 lines above and below line in file where exception was raised) diff --git a/lib/pry.rb b/lib/pry.rb index a5419c2b..57ce782d 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -35,6 +35,16 @@ class Pry Helpers::BaseHelpers.stagger_output("=> #{Helpers::BaseHelpers.colorize_code(stringified)}", output) end + # may be convenient when working with enormous objects and + # pretty_print is too slow + SIMPLE_PRINT = proc do |output, value| + begin + output.puts "=> #{value.inspect}" + rescue RescuableException + output.puts "=> unknown" + end + end + # Will only show the first line of the backtrace DEFAULT_EXCEPTION_HANDLER = proc do |output, exception| output.puts "#{exception.class}: #{exception.message}" @@ -84,7 +94,21 @@ class Pry SHELL_PROMPT = [ proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " }, proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " } - ] + ] + + # A prompt that includes the full object path as well as + # input/output (_in_ and _out_) information. Good for navigation. + NAV_PROMPT = [ + proc do |_, level, pry| + tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / " + "[#{pry.input_array.size}] (pry) #{tree}: #{level}> " + end, + proc do |_, level, pry| + tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / " + "[#{pry.input_array.size}] (pry) #{tree}: #{level}* " + end, + ] + # As a REPL, we often want to catch any unexpected exceptions that may have # been raised; however we don't want to go overboard and prevent the user diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 9b5b3cf6..a9f5fb9f 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.9.4pre1" + VERSION = "0.9.4pre2" end