2012-08-11 17:22:29 -07:00
|
|
|
class Pry
|
2012-12-25 23:35:17 +02:00
|
|
|
class Command::PryBacktrace < Pry::ClassCommand
|
|
|
|
match 'pry-backtrace'
|
2012-08-11 18:26:59 -07:00
|
|
|
group 'Context'
|
2012-12-25 23:35:17 +02:00
|
|
|
description 'Show the backtrace for the Pry session.'
|
2012-08-11 18:26:59 -07:00
|
|
|
|
2012-08-11 17:22:29 -07:00
|
|
|
banner <<-BANNER
|
2013-01-09 22:23:19 +02:00
|
|
|
Usage: pry-backtrace [OPTIONS] [--help]
|
2012-08-11 17:22:29 -07:00
|
|
|
|
2013-01-09 22:23:19 +02:00
|
|
|
Show the backtrace for the position in the code where Pry was started. This can
|
|
|
|
be used to infer the behavior of the program immediately before it entered Pry,
|
|
|
|
just like the backtrace property of an exception.
|
2012-08-11 17:22:29 -07:00
|
|
|
|
2013-01-09 22:23:19 +02:00
|
|
|
NOTE: if you are looking for the backtrace of the most recent exception raised,
|
|
|
|
just type: `_ex_.backtrace` instead.
|
|
|
|
See: https://github.com/pry/pry/wiki/Special-Locals
|
2012-08-11 17:22:29 -07:00
|
|
|
BANNER
|
|
|
|
|
|
|
|
def process
|
2014-04-30 02:08:29 -07:00
|
|
|
_pry_.pager.page text.bold('Backtrace:') << "\n--\n" << _pry_.backtrace.join("\n")
|
2012-08-11 17:22:29 -07:00
|
|
|
end
|
|
|
|
end
|
2012-12-25 23:35:17 +02:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::PryBacktrace)
|
2012-08-11 17:22:29 -07:00
|
|
|
end
|