2012-03-01 20:04:28 -05:00
|
|
|
class Pry
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::Cd < Pry::ClassCommand
|
|
|
|
match 'cd'
|
|
|
|
group 'Context'
|
|
|
|
description 'Move into a new context (object or scope).'
|
2012-03-01 20:04:28 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
banner <<-BANNER
|
|
|
|
Usage: cd [OPTIONS] [--help]
|
2012-03-01 20:04:28 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
Move into new context (object or scope). As in unix shells use
|
|
|
|
`cd ..` to go back, `cd /` to return to Pry top-level and `cd -`
|
|
|
|
to toggle between last two scopes).
|
|
|
|
Complex syntax (e.g `cd ../@x/y`) also supported.
|
2012-03-01 20:04:28 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
e.g: `cd @x`
|
|
|
|
e.g: `cd ..`
|
|
|
|
e.g: `cd /`
|
|
|
|
e.g: `cd -`
|
2012-03-01 20:04:28 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
|
|
|
|
BANNER
|
2012-03-01 20:04:28 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
def process
|
2012-08-17 02:31:03 -04:00
|
|
|
state.old_stack ||= []
|
|
|
|
stack, state.old_stack = context_from_object_path(arg_string, _pry_, state.old_stack)
|
|
|
|
_pry_.binding_stack = stack if stack
|
2012-08-04 15:39:46 -04:00
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::Cd)
|
2012-03-01 20:04:28 -05:00
|
|
|
end
|