Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- command "cd", "Move into a new context (use `cd ..` to go back and `cd /` to return to Pry top-level)" do |obj|
- path = arg_string.split(/\//)
- stack = _pry_.binding_stack.dup
- # special case when we only get a single "/", return to root
- stack = [stack.first] if path.empty?
- resolve_failure = false
- path.each do |context|
- begin
- case context
- when ""
- stack = [stack.first]
- when "."
- next
- when ".."
- if stack.one?
- _pry_.binding_stack.clear
- throw(:breakout)
- else
- stack.pop
- end
- else
- stack.push(Pry.binding_for(stack.last.eval(context)))
- end
- rescue RescuableException
- output.puts "Bad object path: #{arg_string}. Failed trying to resolve: #{context}"
- resolve_failure = true
- end
- end
- next if resolve_failure
- _pry_.binding_stack = stack
- end
Add Comment
Please, Sign In to add comment