Sha256: b3fd35c115ac764be11d2b7ccc063aa69070e1d09bed8680d18e9f92a839822d

Contents?: true

Size: 955 Bytes

Versions: 12

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

require "byebug/command"
require "irb"
require "English"

module Byebug
  #
  # Enter IRB from byebug's prompt
  #
  class IrbCommand < Command
    self.allow_in_post_mortem = true

    def self.regexp
      /^\s* irb \s*$/x
    end

    def self.description
      <<-DESCRIPTION
        irb

        #{short_description}
      DESCRIPTION
    end

    def self.short_description
      "Starts an IRB session"
    end

    def execute
      unless processor.interface.instance_of?(LocalInterface)
        return errmsg(pr("base.errors.only_local"))
      end

      # @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a
      #   test case for it so we can remove this comment.
      with_clean_argv { IRB.start }
    end

    private

    def with_clean_argv
      saved_argv = $ARGV.dup
      $ARGV.clear
      begin
        yield
      ensure
        $ARGV.concat(saved_argv)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/byebug-10.0.2/lib/byebug/commands/irb.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/commands/irb.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/commands/irb.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/byebug-10.0.2/lib/byebug/commands/irb.rb
jets-0.5.5 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/irb.rb
jets-0.5.4 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/irb.rb
jets-0.5.3 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/irb.rb
jets-0.5.2 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/irb.rb
jets-0.5.1 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/irb.rb
byebug-10.0.2 lib/byebug/commands/irb.rb
byebug-10.0.1 lib/byebug/commands/irb.rb
byebug-10.0.0 lib/byebug/commands/irb.rb