pry--pry/lib/pry/commands/cd.rb

32 lines
850 B
Ruby
Raw Normal View History

class Pry
class Command::Cd < Pry::ClassCommand
match 'cd'
group 'Context'
description 'Move into a new context (object or scope).'
banner <<-BANNER
Usage: cd [OPTIONS] [--help]
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.
e.g: `cd @x`
e.g: `cd ..`
e.g: `cd /`
e.g: `cd -`
https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
BANNER
def process
2012-08-17 06:31:03 +00: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 19:39:46 +00:00
end
end
Pry::Commands.add_command(Pry::Command::Cd)
end