Sha256: c9ca6af2a595e70281007dc200a4600514b86aeafa5e7836bf2742cee13f1cd8

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'byebug/states/control_state'

module Byebug
  #
  # Processes commands in 'control' mode, when there's no program running
  #
  class ControlCommandProcessor < Processor
    attr_reader :state

    def initialize(interface = LocalInterface.new)
      super(interface)
    end

    def commands
      Command.commands.select(&:allow_in_control).map { |cmd| cmd.new(state) }
    end

    def process_commands
      @state = ControlState.new(interface)

      while (input = @interface.read_command(prompt(nil)))
        cmd = commands.find { |c| c.match(input) }
        unless cmd
          errmsg('Unknown command')
          next
        end

        cmd.execute
      end

      @interface.close
    rescue IOError, SystemCallError
      @interface.close
    rescue
      without_exceptions do
        puts "INTERNAL ERROR!!! #{$ERROR_INFO}"
        puts $ERROR_INFO.backtrace.map { |l| "\t#{l}" }.join("\n")
      end
    end

    #
    # Prompt shown before reading a command.
    #
    def prompt(_context)
      '(byebug:ctrl) '
    end
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/byebug-4.0.5/lib/byebug/processors/control_command_processor.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/byebug-4.0.5/lib/byebug/processors/control_command_processor.rb
byebug-4.0.5 lib/byebug/processors/control_command_processor.rb
byebug-4.0.4 lib/byebug/processors/control_command_processor.rb
byebug-4.0.3 lib/byebug/processors/control_command_processor.rb
byebug-4.0.2 lib/byebug/processors/control_command_processor.rb
byebug-4.0.1 lib/byebug/processors/control_command_processor.rb
byebug-4.0.0 lib/byebug/processors/control_command_processor.rb