lib/byebug/processors/command_processor.rb in byebug-9.1.0 vs lib/byebug/processors/command_processor.rb in byebug-10.0.0
- old
+ new
@@ -1,10 +1,12 @@
-require 'forwardable'
+# frozen_string_literal: true
-require 'byebug/helpers/eval'
-require 'byebug/errors'
+require "forwardable"
+require "byebug/helpers/eval"
+require "byebug/errors"
+
module Byebug
#
# Processes commands in regular mode.
#
# You can override this class to create your own command processor that, for
@@ -14,23 +16,20 @@
#
class CommandProcessor
include Helpers::EvalHelper
attr_accessor :prev_line
- attr_reader :context
+ attr_reader :context, :interface
- def initialize(context)
+ def initialize(context, interface = LocalInterface.new)
@context = context
+ @interface = interface
@proceed = false
@prev_line = nil
end
- def interface
- @interface ||= Context.interface
- end
-
def printer
@printer ||= Printers::Plain.new
end
extend Forwardable
@@ -104,11 +103,11 @@
#
# Prompt shown before reading a command.
#
def prompt
- '(byebug) '
+ "(byebug) "
end
def before_repl
@proceed = false
@prev_line = nil
@@ -127,11 +126,11 @@
def repl
until @proceed
cmd = interface.read_command(prompt)
return if cmd.nil?
- next if cmd == ''
+ next if cmd == ""
run_cmd(cmd)
end
end
@@ -165,10 +164,10 @@
end
end
def safely
yield
- rescue => e
+ rescue StandardError => e
errmsg(e.message)
end
end
end