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-client-0.0.1.alpha72 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha71 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha70 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha69 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha68 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha67 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha66 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-oathkeeper-client-0.38.19.beta1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-oathkeeper-client-0.38.18.beta1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-oathkeeper-client-0.38.17.beta1 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
avalara_sdk-2.4.7 vendor/bundle/ruby/2.6.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha58 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha57 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha56 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha55 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha54 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha53 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha52 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha51 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb
ory-client-0.0.1.alpha50 vendor/bundle/ruby/2.5.0/gems/pry-0.13.1/lib/pry/commands/cd.rb