class Byebug::SourceCommand - byebug-4.0.5 Documentation

# class Byebug::SourceCommand

Execute a file containing byebug commands.

It can be used to restore a previously saved debugging session.

### Public Class Methods

description() click to toggle source

    # File lib/byebug/commands/source.rb, line 36
    def description
      prettify <<-EOD
        source <file>

        Executes file <file> containing byebug commands.
      EOD
    end

names() click to toggle source

    # File lib/byebug/commands/source.rb, line 32
    def names
      %w(source)
    end

### Public Instance Methods

execute() click to toggle source

    # File lib/byebug/commands/source.rb, line 16
    def execute
      return puts(self.class.help) if self.class.names.include?(@match[0])

      unless @state && @state.interface
        return errmsg(pr('source.errors.not_available'))
      end

      file = File.expand_path(@match[1]).strip
      unless File.exist?(file)
        return errmsg(pr('source.errors.not_found', file: file))
      end

      @state.interface.read_file(file)
    end

regexp() click to toggle source

    # File lib/byebug/commands/source.rb, line 12
    def regexp
      /^\s* so(?:urce)? (?:\s+(\S+))? \s*$/x
    end