Sha256: 44410f2d5fa04ae6ae898295f1e4120eb3773d032e378e09954af4c0700dd2d3

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

require 'byebug/command'
require 'irb'

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
      <<-EOD
        irb

        #{short_description}
      EOD
    end

    def self.short_description
      'Starts an IRB session'
    end

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

      # IRB tries to parse ARGV so we must clear it.  See issue 197
      with_clean_argv { IRB.start(__FILE__) }
    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

3 entries across 3 versions & 1 rubygems

Version Path
byebug-8.2.5 lib/byebug/commands/irb.rb
byebug-8.2.4 lib/byebug/commands/irb.rb
byebug-8.2.3 lib/byebug/commands/irb.rb