mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
added Pry::NAV_PROMPT and Pry::SIMPLE_PRINT to pry.rb
NAV_PROMPT shows you your current context along with all the previous contexts separated by a "/" a la shell-style; making it easier to navigate around. Also includes current index of _in_ and _out_ locals. SIMPLE_PRINT is just a simple inspect style printer (a la IRB); it doesnt use coloration or pretty printing or paging and can die for weird input. But is likely slightly faster for large output
This commit is contained in:
parent
9a2a1bdb34
commit
522e7bc203
3 changed files with 27 additions and 2 deletions
|
@ -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)
|
||||
|
|
24
lib/pry.rb
24
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}"
|
||||
|
@ -86,6 +96,20 @@ class Pry
|
|||
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
|
||||
# from exiting Pry when they want to.
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Pry
|
||||
VERSION = "0.9.4pre1"
|
||||
VERSION = "0.9.4pre2"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue