Sha256: f05614042d338bd4689d0b3156fdbf3da29ececca2cf4004cf9458a2d1d62c4e

Contents?: true

Size: 1.23 KB

Versions: 6837

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

class Pry
  class Command
    class 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.

        cd @x
        cd ..
        cd /
        cd -

        https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
      BANNER

      def process
        state.old_stack ||= []

        if arg_string.strip == "-"
          unless state.old_stack.empty?
            pry_instance.binding_stack, state.old_stack =
              state.old_stack, pry_instance.binding_stack
          end
        else
          stack = ObjectPath.new(arg_string, pry_instance.binding_stack).resolve

          if stack && stack != pry_instance.binding_stack
            state.old_stack = pry_instance.binding_stack
            pry_instance.binding_stack = stack
          end
        end
      end
    end

    Pry::Commands.add_command(Pry::Command::Cd)
  end
end

Version data entries

6,837 entries across 6,832 versions & 33 rubygems

Version Path
ory-oathkeeper-client-0.38.20.beta1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha91 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha90 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha89 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha88 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha87 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha86 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha85 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha84 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha83 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha82 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha81 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha80 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha79 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha78 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha77 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha76 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha75 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha74 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha73 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb