Sha256: f05614042d338bd4689d0b3156fdbf3da29ececca2cf4004cf9458a2d1d62c4e

Contents?: true

Size: 1.23 KB

Versions: 6836

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,836 entries across 6,831 versions & 33 rubygems

Version Path
ory-client-0.0.1.alpha29 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
primary_connect_proto-0.0.6 vendor/bundle/ruby/2.6.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha28 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
primary_connect_proto-0.0.5 vendor/bundle/ruby/2.6.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha27 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha24 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
primary_connect_proto-0.0.4 vendor/bundle/ruby/2.6.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
primary_connect_proto-0.0.3 vendor/bundle/ruby/2.6.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha23 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.8.0.alpha2 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha21 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-keto-client-0.7.0.alpha1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-keto-client-0.7.0.alpha0 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha7 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha6 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha5 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha4 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha3 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.6.alpha1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-kratos-client-0.7.5.alpha2 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb