Sha256: 543db3ee5d80658418fe8b94012501d8efa0a35156d7bb4847c4e06b873b65ff

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

class Pry
  class Command::Exit < Pry::ClassCommand
    match 'exit'
    group 'Navigating Pry'
    description 'Pop the previous binding.'
    command_options keep_retval: true

    banner <<-'BANNER'
      Usage:   exit [OPTIONS] [--help]
      Aliases: quit

      Pop the previous binding (does NOT exit program). It can be useful to exit a
      context with a user-provided value. For instance an exit value can be used to
      determine program flow.

      exit "pry this"
      exit

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

    def process
      if _pry_.binding_stack.one?
        _pry_.run_command "exit-all #{arg_string}"
      else
        # otherwise just pop a binding and return user supplied value
        process_pop_and_return
      end
    end

    def process_pop_and_return
      popped_object = _pry_.binding_stack.pop.eval('self')

      # return a user-specified value if given otherwise return the object
      return target.eval(arg_string) unless arg_string.empty?

      popped_object
    end
  end

  Pry::Commands.add_command(Pry::Command::Exit)
  Pry::Commands.alias_command 'quit', 'exit'
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
chess_engine-0.0.2 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb
chess_engine-0.0.1 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/exit.rb
pry-0.12.2-java lib/pry/commands/exit.rb
pry-0.12.2 lib/pry/commands/exit.rb
pry-0.12.1 lib/pry/commands/exit.rb
pry-0.12.1-java lib/pry/commands/exit.rb
pry-0.12.0 lib/pry/commands/exit.rb
pry-0.12.0-java lib/pry/commands/exit.rb