2012-08-11 20:22:29 -04:00
|
|
|
class Pry
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::SwitchTo < Pry::ClassCommand
|
|
|
|
match 'switch-to'
|
2012-08-11 21:26:59 -04:00
|
|
|
group 'Navigating Pry'
|
2013-01-09 15:23:19 -05:00
|
|
|
description 'Start a new subsession on a binding in the current stack.'
|
|
|
|
|
|
|
|
banner <<-'BANNER'
|
|
|
|
Start a new subsession on a binding in the current stack (numbered by nesting).
|
|
|
|
BANNER
|
2012-08-11 20:22:29 -04:00
|
|
|
|
2012-08-11 21:26:59 -04:00
|
|
|
def process(selection)
|
|
|
|
selection = selection.to_i
|
|
|
|
|
|
|
|
if selection < 0 || selection > _pry_.binding_stack.size - 1
|
|
|
|
raise CommandError, "Invalid binding index #{selection} - use `nesting` command to view valid indices."
|
|
|
|
else
|
|
|
|
Pry.start(_pry_.binding_stack[selection])
|
|
|
|
end
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::SwitchTo)
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|